不多说, 上代码:
void C 目录选择对话框 Dlg::OnBnClickedButton1()
- {
- TCHAR szPath[MAX_PATH] = { 0 };
- BROWSEINFO mBroInfo = { 0 };/*Contains parameters for the SHBrowseForFolder function
- and receives information about the folder selected by the user*/
- mBroInfo.hwndOwner = m_hWnd;
- ITEMIDLIST *pidl = SHBrowseForFolder(&mBroInfo);
- if (SHGetPathFromIDList(pidl, szPath)) { //Converts an item identifier list to a file system path
- SetDlgItemText(IDC_EDIT1, szPath);
- }
- CoTaskMemFree(pidl);// 释放 ITEMIDLIST 指针
- }
来源: http://www.bubuko.com/infodetail-3358609.html