#keywords MFC,path {{{#!gcode static int CALLBACK BrowseCallbakProc(HWND hWnd, UINT uMsg, LPARAM lParam, LPARAM pData) { switch(uMsg) { case BFFM_VALIDATEFAILED: CString strText; strText.Format(_T("%s"), reinterpret_cast(lParam)); AfxMessageBox((LPCTSTR)strText); break; } return 0; } . . . void CC3AllPathContentsFinderDlg::OnBnClickedButton1() { ITEMIDLIST *pildBrowse; WCHAR pathName[MAX_PATH]; LPITEMIDLIST pidl = NULL; BROWSEINFO bInfo; ZeroMemory(&bInfo, sizeof(BROWSEINFO)); SHPathToPidl(CSIDL_DESKTOP, &pidl); // 루트 디렉토리 설정 부분. bInfo.hwndOwner = GetSafeHwnd(); bInfo.pidlRoot = pidl; bInfo.pszDisplayName = pathName; bInfo.lpszTitle = _T("검색할 디렉토리를 골라주세용"); bInfo.lpfn = BrowseCallbakProc; // 콜백함수가 필요없다면 NULL이나 지움. 위의 static int 함수 필요 없어짐 bInfo.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_VALIDATE ; // 디렉토리만 설정가능하도록 하였습니다... 플래그 설정은 맨 아래 참조하세요, 또는 MSDN pildBrowse = ::SHBrowseForFolder(&bInfo); CString cs; if( pildBrowse != NULL ) { SHGetPathFromIDList(pildBrowse, pathName); cs.Format(_T("%s"), pathName); AfxMessageBox((LPCTSTR)cs); UpdateData(FALSE); } } HRESULT CC3AllPathContentsFinderDlg::SHPathToPidl(LPWSTR path, LPITEMIDLIST* ppidl) { LPSHELLFOLDER pShellFolder = NULL; OLECHAR wszPath[MAX_PATH] = {0}; ULONG nCharsParsed = 0; HRESULT hr = SHGetDesktopFolder(&pShellFolder); if(FAILED(hr)) return FALSE; hr = pShellFolder->ParseDisplayName(NULL, NULL, path, &nCharsParsed, ppidl, NULL); pShellFolder->Release(); return hr; } }}} ---- attachment:scr001.png