Hi there!!
How can I display a window in which I can select a directory, which path I can use afterwards?
I made it once before,but now I just can't find it!!!
Thx
Han
Printable View
Hi there!!
How can I display a window in which I can select a directory, which path I can use afterwards?
I made it once before,but now I just can't find it!!!
Thx
Han
Assuming you're talking about Windows, try here.
In windows the following function will display the directory box and return the directory selected as a CString.
Code:CString GetFolderPath()
{
CoInitialize(0);
char szDirectory[1024];
HRESULT hr;
BROWSEINFO browseInfo;
LPITEMIDLIST lpItemList=0;
LPMALLOC lpM;
hr = SHGetMalloc (&lpM) ;
if (FAILED(hr) ) return _T("");
ZeroMemory ( (PVOID) &browseInfo,sizeof (BROWSEINFO));
browseInfo.pidlRoot = 0;
browseInfo.hwndOwner = NULL;
browseInfo.pszDisplayName = szDirectory;
browseInfo.lpszTitle = "Open Folder ";
browseInfo.ulFlags = BIF_RETURNFSANCESTORS|BIF_RETURNONLYFSDIRS;
browseInfo.lParam = 0;
if ((lpItemList = SHBrowseForFolder(&browseInfo)) == NULL)
{
return _T("");
}
SHGetPathFromIDList(lpItemList,szDirectory);
lpM->Free(lpItemList);
lpM->Release();
CString strPath;
strPath = _T(szDirectory);
return strPath;
}