Hi:
I got a quite weird problem--->
I was intializing the OPENFILENAME structure before calling
GetSaveFileName(&ofn).
Code:
OPENFILENAME ofn;
char szFileName[MAX_PATH] = "Untitled";
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFileName; //set default file name
ofn.nMaxFile = MAX_PATH; //260 Max. characters
........
ofn.lpstrDefExt = "txt";//always add txt if no file extension added
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
Then called GetSaveFileName(&ofn) ,it was just fine, but when I changed
Code:
ofn.lpstrFile = szFileName;
into:
ofn.lpstrFile = "Untitled";
program crashed when running it.
I don't know what is going on? I think they are doing the same thing. Anyone knows that? Thanks.