Finding a directory
-
Thanks for your help to people who ask queries. I know how to ask for a file to read from, or a file to write to :-
BOOL GetFileName(HWND wn,char*file,char*titl,char*filter,short write/*=1*/) {short j;
strcpy(file,title);
ofn.lStructSize=sizeof(OPENFILENAME); ofn.hwndOwner=wn;
ofn.lpstrFilter=filter; ofn.lpstrCustomFilter=0;
ofn.lpstrFile=file; ofn.nMaxFile=1024;
ofn.lpstrFileTitle=title; ofn.nMaxFileTitle=1024;
ofn.lpstrInitialDir=0; ofn.lpstrTitle=titl;
ofn.Flags=write?OFN_OVERWRITEPROMPT:OFN_FILEMUSTEXIST;
j=(write?GetSaveFileName(&ofn):GetOpenFileName(&ofn))?1:0;
return j;}('ofn' and 'title' are declared globally.) but when I need to ask for a directory / folder, I must do something like this:
K=GetFileName(wn, slidefilename, "name of a file in the directory to read slides from?", slidefiletype, 0);
Is there something like GetOpenFileName, but returning the name of a directory rather than the name of a file?
-
Thanks for your help to people who ask queries. I know how to ask for a file to read from, or a file to write to :-
BOOL GetFileName(HWND wn,char*file,char*titl,char*filter,short write/*=1*/) {short j;
strcpy(file,title);
ofn.lStructSize=sizeof(OPENFILENAME); ofn.hwndOwner=wn;
ofn.lpstrFilter=filter; ofn.lpstrCustomFilter=0;
ofn.lpstrFile=file; ofn.nMaxFile=1024;
ofn.lpstrFileTitle=title; ofn.nMaxFileTitle=1024;
ofn.lpstrInitialDir=0; ofn.lpstrTitle=titl;
ofn.Flags=write?OFN_OVERWRITEPROMPT:OFN_FILEMUSTEXIST;
j=(write?GetSaveFileName(&ofn):GetOpenFileName(&ofn))?1:0;
return j;}('ofn' and 'title' are declared globally.) but when I need to ask for a directory / folder, I must do something like this:
K=GetFileName(wn, slidefilename, "name of a file in the directory to read slides from?", slidefiletype, 0);
Is there something like GetOpenFileName, but returning the name of a directory rather than the name of a file?
SHBrowseForFolder SHBrowseForFolderA function (shlobj_core.h) - Win32 apps | Microsoft Docs[^] CodeProject has a sample app How to Browse for a Folder[^]
In vino veritas