我正在尝试使用这行代码
startingfolder = _T("C:\\VSS\\" + caseref);
但据我了解,我不允许在变量上使用 _T。基本上我试图将 SHBrowseForFolder 的起始文件夹设置为由之前分配的变量组成的路径。我花了很长时间试图绕过它,一直在搜索并找到有关 wstrings 的东西,但似乎没有任何效果。我希望我错过了一些容易的事情,因为我无法相信 _T 变量这么难。
void folderdialog2()
{
PIDLIST_ABSOLUTE xx;
PCTSTR startingfolder;
startingfolder = _T("C:\\VSS\\" + caseref);
xx = ILCreateFromPath(startingfolder);
BROWSEINFO bi = { 0 };
bi.pidlRoot = xx;
bi.lpszTitle = _T("Pick a Directory");
LPITEMIDLIST pidl = SHBrowseForFolder ( &bi );
if ( pidl != 0 )
{
// get the name of the folder
TCHAR path[MAX_PATH];
if ( SHGetPathFromIDList ( pidl, path ) )
{
_tprintf ( _T("Selected Folder: %s\n"), path );
}
// free memory used
IMalloc * imalloc = 0;
if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )
{
imalloc->Free ( pidl );
imalloc->Release ( );
}
}
}