MFC 选择目录
本函数封装了一段 Windows API,实现选择目录:
CString select_path() { BROWSEINFO bi = {0}; bi.lpszTitle = _T("选择目录"); LPITEMIDLIST pidl = SHBrowseForFolder(&bi); if (!pidl) { return _T(""); } TCHAR path[MAX_PATH]; SHGetPathFromIDList(pidl, path); IMalloc * imalloc = 0; if (SUCCEEDED(SHGetMalloc(&imalloc))) { imalloc->Free(pidl); imalloc->Release(); } return path; }