BOOL CTableLook5020Dlg::GetDirectory(CString &Directory, char *strMsg) { BROWSEINFO bi; bi.hwndOwner=this->m_hWnd; //owner of created dialog box bi.pidlRoot=0; //unused bi.pszDisplayName=0; //buffer to receive name displayed by folder (not a valid path) bi.lpszTitle = strMsg; //title is "Browse for Folder", this is an instruction bi.lpfn = NULL; //callback routine called when dialog has been initialized bi.lParam=0; //passed to callback routine bi.ulFlags= BIF_RETURNONLYFSDIRS | //only allow user to select a directory BIF_STATUSTEXT | //create status text field we will be writing to in callback 0; LPITEMIDLIST lpItemId=::SHBrowseForFolder(&bi); if(lpItemId == NULL) return FALSE; if (lpItemId) { LPTSTR szBuf=Directory.GetBuffer(MAX_PATH); ::SHGetPathFromIDList(lpItemId, szBuf); ::GlobalFree(lpItemId); Directory.ReleaseBuffer(); } return TRUE; }
{
BROWSEINFO bi;
bi.hwndOwner=this->m_hWnd; //owner of created dialog box
bi.pidlRoot=0; //unused
bi.pszDisplayName=0; //buffer to receive name displayed by folder (not a valid path)
bi.lpszTitle = strMsg; //title is "Browse for Folder", this is an instruction
bi.lpfn = NULL; //callback routine called when dialog has been initialized
bi.lParam=0; //passed to callback routine
bi.ulFlags=
BIF_RETURNONLYFSDIRS | //only allow user to select a directory
BIF_STATUSTEXT | //create status text field we will be writing to in callback
0;
LPITEMIDLIST lpItemId=::SHBrowseForFolder(&bi);
if(lpItemId == NULL)
return FALSE;
if (lpItemId)
{
LPTSTR szBuf=Directory.GetBuffer(MAX_PATH);
::SHGetPathFromIDList(lpItemId, szBuf);
::GlobalFree(lpItemId);
Directory.ReleaseBuffer();
}
return TRUE;
}