मैं fileName मेरी फाइल को बचाने के लिए प्राप्त करने के लिए इस कोड को लिखें:Win32 में GetSaveFileName के साथ फ़ाइल को कैसे सहेजना है?
#include "stdafx.h"
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFilter = (LPCWSTR)L"Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
ofn.lpstrFile = (LPWSTR)szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = (LPCWSTR)L"txt";
GetSaveFileName(&ofn);
printf("the path is : %s\n", ofn.lpstrFile);
getchar();
return 0;
}
लेकिन उत्पादन होता है:
the path is : H
क्यों? क्या मुझसे कुछ गलत हो रही है ?
printf("the path is : %s\n", ofn.lpstrFile);
printf की व्यापक चार संस्करण का उपयोग करना चाहिए:
मैं Windows 7.
+1। –