Hi people

I need a little help with GetOpenFileName.

I want it to return just the path without the file name,
or should I say, I want to select a directory and not the file.
So that the function would return the directory path without the need to define a file name.

One posibilitie is to set up a hook, but is there any other option.

Posted on 2002-04-20 15:16:19 by Mostek
If you want to select a file and only get it's path, just scan the filename string backwards until you find the first backslash. Place a 0 byte after it and you'll have the file's path.
Or use the nFileOffset member of the OPENFILENAME struct. This member is a zero-based index in the filename of the file part.

However if your goal is to let the user select a directory only (not necessarily a file), you probably need some hook. An alternative is to use the masm32 lib function BrowseForFolder, which will show a common dialog with a folder list and return the path of the folder selected by the user.

Posted on 2002-04-20 16:47:36 by Thomas
As I'm currently working on ida2sice plugIn (c/c++) I can't import masm library functions. :(
Well THE hook it is.

I just wanted to know if there are some specials options that I don't know about.

Anyway thanks a lot. And MAN must I say you are faaasssttt. :)

Posted on 2002-04-20 17:07:30 by Mostek
As I'm currently working on ida2sice plugIn (c/c++) I can't import masm library functions. :(

Why not?

// assuming you are using C++
extern "C" bool __stdcall BrowseForFolder(HWND hParent, char *lpBuffer, char *lpTitle, char *lpString);

Or use the C version:

// lpTitle not implemented
bool browseForFolder(HWND hParent, char *lpBuffer, char *lpString)
bool retval;
bi.hwndOwner = hParent;
bi.pidlRoot = 0;
bi.pszDisplayName = 0;
bi.lpszTitle = lpString;
bi.lpfn = NULL;
bi.iImage = 0;
if (lpIDList = SHBrowseForFolder(&bi))
SHGetPathFromIDList(lpIDList, lpBuffer);
retval = true;
retval = false;

return retval;
Posted on 2002-04-20 17:18:27 by Thomas
I don't know why, but I always thought that MASM has some special libraries that can be read only by masm.

Well as I'm TASM programer I didn't go to deep on that.

I'm thinking to start using MASM for quite some time, but I never got to it. :(

That's why you are "Mad Wizard, programmer" and I'm only a "Code Warrior".
You are programming and I'm still fighting with the code. ;)


Posted on 2002-04-20 18:20:17 by Mostek