I am implementing an OFNHookProc
to instrument a common controls GetOpenFileName()
dialog on Windows 7. My instrumentation is written in C++. Things work fine until the user selects a Library (like Documents or Pictures). When this happens, I get the CDN_FOLDERCHANGE
notification like I expect, but when I send the dialog the CDM_GETFOLDERPATH
message to retrieve the newly selected folder, I get an error return of -1, with CommDlgExtendedError
returning 0. In some ways, this makes sense, since it's not a folder, but none of the other messages seem to work either (like CDM_GETFOLDERIDLIST
or CDM_GETFILEPATH
).
So, how do you tell from an OFNHookProc
that the currently selected item or folder is a library? Once you can tell that it's a library, how do you get an IShellItem
or IShellLibrary
interface to it such that you can figure out what file system folders constitute the library?
(The code that creates the GetOpenFileName
dialog is legacy code, so I can't replace it with the Windows-7-recommended IFileOpenDialog
interface that supports Libraries in a sane manner).