I got a quite weird problem--->
I was intializing the OPENFILENAME structure before calling
Then called GetSaveFileName(&ofn) ,it was just fine, but when I changed
char szFileName[MAX_PATH] = "Untitled";
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;
program crashed when running it.
ofn.lpstrFile = szFileName;
ofn.lpstrFile = "Untitled";
I don't know what is going on? I think they are doing the same thing. Anyone knows that? Thanks.
lpstrFile shall point to a buffer which is to receive input.
"Untitled" is a string constant.