Question and Answer Database FAQ3C.txt Browse for Folder/Directory Category :Windows API Platform :All Product :C++Builder 1.x Question: How do I let a user browse for a directory? Answer: Use SHBrowseForFolder() like so: #include//----------------------------------------------------------------- void __fastcall TFormX::BrowseForFolderButtonClick(TObject *Sender) { BROWSEINFO BrowsingInfo; char DirPath[MAX_PATH]; char FolderName[MAX_PATH]; LPITEMIDLIST ItemID; memset(&BrowsingInfo, 0, sizeof(BROWSEINFO)); memset(DirPath, 0, MAX_PATH); BrowsingInfo.hwndOwner = FormX->Handle; BrowsingInfo.pszDisplayName = FolderName; BrowsingInfo.lpszTitle = "Al's browsing example."; ItemID = SHBrowseForFolder(&BrowsingInfo); SHGetPathFromIDList(ItemID, DirPath); MessageBox(FormX->Handle, DirPath, "The Chosen One", MB_OK); GlobalFreePtr(ItemID); } The last 'function' is a Macro defined in 7/2/98 10:32:32 AM
Last Modified: 01-SEP-99