DirectoryPath (폴더 선택) 선택하기
MFC&ActiveX/MFC Copy Code 2008. 10. 8. 14:25 |void ChoiceDirectoryPath(char* pathFolder)
{
ASSERT( pathFolder );
sprintf( pathFolder, "" );
//CString m_strDirPath;
ITEMIDLIST *pidlBrowse;
char pszPathname[MAX_PATH];
BROWSEINFO BrInfo;
BrInfo.hwndOwner = NULL; //GetSafeHwnd();
BrInfo.pidlRoot = NULL;
memset( &BrInfo, 0, sizeof(BrInfo) );
BrInfo.pszDisplayName = (LPSTR)pszPathname;
BrInfo.lpszTitle = _T("폴더를 선택해 주세요.");
BrInfo.ulFlags = BIF_RETURNONLYFSDIRS;
// 다이얼로그 뛰우기
pidlBrowse = SHBrowseForFolder(&BrInfo);
if(pidlBrowse != NULL)
{
BOOL bSuccess = ::SHGetPathFromIDList(pidlBrowse, (LPSTR)pszPathname);
if( bSuccess )
{
sprintf( pathFolder, "%s", pszPathname );
}
}
}
// 사용할때
char szDirectory[MAX_PATH];
ZeroMemory( szDirectory, sizeof(szDirectory) );
ChoiceDirectoryPath( szDirectory );
if( strlen(szDirectory) <= 0 )
return 0;