MFC Win32程序打开选择目录对话框并获得绝对路径

			TCHAR           szFolderPath[MAX_PATH] = { 0 };

			BROWSEINFO      sInfo;
			::ZeroMemory(&sInfo, sizeof(BROWSEINFO));
			sInfo.pidlRoot = 0;
			sInfo.lpszTitle = _T("请选择一个文件夹:");
			sInfo.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE | BIF_EDITBOX;
			sInfo.lpfn = NULL;

			// 显示文件夹选择对话框  
			LPITEMIDLIST lpidlBrowse = ::SHBrowseForFolder(&sInfo);
			if (lpidlBrowse != NULL)
			{
				// 取得文件夹名  
				if (::SHGetPathFromIDList(lpidlBrowse, szFolderPath))
				{
				}
			}
			if (lpidlBrowse != NULL)
			{
				::CoTaskMemFree(lpidlBrowse);
			}

你可能感兴趣的:(c++)