SHGetPathFromID under WinXP vs Win2000
-
Problem: Code working for a long time under WinME/2000/98 does not work under WinXP. Little function to pop up a dialog box and allow the user to pick a folder (or file) which is returned as a CString. I get back the wrong value if user creates new folder or types non-existing folder into box. What I'm looking for: Function to pop up dialog and get back existing or new folder as specified by user. Symptoms: Works just as I would expect it to under Win98/ME/2000. Under WinXP if the user creates a folder, or types a new folder into the edit box I get back a reference to their user directory. (Please excuse a bit of 'debugging mess' I'm still trying to figure out what is going on). Also, there are some header files that I don't have the latest versions of, being limited to VC6 with all patches (so you can ignore my comments about BIF_USENEWUI - which is documented but appears at some later point I think). I didn't see any KB articles related to WinXP for either of my two functions-in-question. Any help would be appreciated! --Mark -----My Test Code------ CString CXpgetfoldercheckDlg::getFolderName(CString title, bool requireTrailingBackslash, bool allowNewFolders) { // PURPOSE: // Uses latest UI to get a folder name. // PARAMS: // title = the title of the browse dialog. // rquireTrailingBackslash = true if you want the last character of the folder to be '\' (default t) // allowNewFolders = true if you want a 'new' button to appear on the dialog (default t) // RETURNS: // valid folder name if successful or NULL if not // REQUIRED: // IE 5.0 on up, or Win2000 on up // STEPS: // Bring up a common file dialog, // Allow the user's to select a folder name // Close the dialog // // KNOWN BUG: Problem with WindowXP (11-2-2001) - typed-in filename (i.e. new file name) returns the // user's mydocuments folder. // Results with the following settings // info.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX; BROWSEINFO info; ITEMIDLIST *list; HRESULT ret; DWORD dwCoInit=COINIT_APARTMENTTHREADED; ret = CoInitializeEx(NULL,dwCoInit); if (ret == S_OK || ret == S_FALSE ) TRACE("CoInitted\n"); else { return "ERR: Failed CoInit"; } //info.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI ; //new // Where are these? // BIF_USENEWUI // BIF_NEWDIALOGSTYLE //FIXME: Could not get the various header issues to work, so I just added the param values