目录选择对话框(实用)

不多说,上代码:

 1 void C目录选择对话框Dlg::OnBnClickedButton1()
 2 {
 3     TCHAR szPath[MAX_PATH] = { 0 };
 4     BROWSEINFO mBroInfo = { 0 };/*Contains parameters for the SHBrowseForFolder function 
 5     and receives information about the folder selected by the user*/
 6     mBroInfo.hwndOwner = m_hWnd;
 7     ITEMIDLIST *pidl = SHBrowseForFolder(&mBroInfo);
 8     if (SHGetPathFromIDList(pidl, szPath)) {  //Converts an item identifier list to a file system path
 9         SetDlgItemText(IDC_EDIT1, szPath);
10     }
11     CoTaskMemFree(pidl);//释放ITEMIDLIST指针
12 }

猜你喜欢

转载自www.cnblogs.com/mktest123/p/12122200.html