OPENFILENAME initialization
look at the following code:
Code:
char filepath[1024] = {0};
OPENFILENAME ofn;
...
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hDlg;
ofn.lpstrFile = filepath;
ofn.nMaxFile = sizeof(filepath);
ofn.lpstrTitle = "Choose A File";
ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
if (GetOpenFileName(&ofn)) {
...
}
i want that the first searching folder be the folder where the program resides. i thought that the above code would do that. but it starts searching from My Documents. what else do i need to start searching from current folder? thanks in advnace.
Re: OPENFILENAME initialization
Yes, if both lpstrFile and lpstrInitialDir are empty, the initial folder is the personal folder. Fill the lpstrInitialDir member to set the initial directory. To get your program's folder, see this faq.