I'm trying to use IFileDialog to select a folder and the following code does this just fine. The problem is I'd like to see certain file types as well as folders while browsing (such as *.txt). Is there a simple way to do this?
//g_path is a global which will contain the selected folders path
void PickContainer()
{
IFileDialog *pfd;
if (SUCCEEDED(CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd))))
{
DWORD dwOptions;
if (SUCCEEDED(pfd->GetOptions(&dwOptions)))
{
pfd->SetOptions(dwOptions | FOS_PICKFOLDERS);
}
if (SUCCEEDED(pfd->Show(NULL)))
{
IShellItem *psi;
if (SUCCEEDED(pfd->GetResult(&psi)))
{
if(!SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &g_path)))
{
MessageBox(NULL, "GetIDListName() failed", NULL, NULL);
}
psi->Release();
}
}
pfd->Release();
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…