Need to get the path to the folder. I use the BROWSEINFO structure and the SHBrowseForFolder () function. But when displaying the resulting path, only the first character is displayed. How to fix it? Already tortured to look.
//get directory of exe file BROWSEINFO bi; LPITEMIDLIST folder = NULL; LPMALLOC shMalloc = NULL; char foldername[MAX_PATH]; char folderpath[MAX_PATH]; string path; memset(&bi, 0, sizeof(bi)); CoInitialize(NULL); SHGetMalloc(&shMalloc); bi.hwndOwner = NULL; bi.pidlRoot = NULL; bi.pszDisplayName = (LPWSTR)foldername; bi.lpszTitle = L"Выберите папку с базой данных:"; bi.ulFlags = BIF_NEWDIALOGSTYLE; folder = SHBrowseForFolder(&bi); if (folder) { SHGetPathFromIDListW(folder, (LPWSTR)folderpath); shMalloc->Free(folder); shMalloc->Release(); printf("Folder selected: %s\n", &folderpath); }
printf("Folder selected: %s\n", &folderpath);- nonsense. What makes this&in the argument? - AnT 7:42 pmSHBrowseForFolder, useIFileOpenDialogwith theFOS_PICKFOLDERSoption. - VTT