本文整理汇总了C++中IFileOpenDialog::AddPlace方法的典型用法代码示例。如果您正苦于以下问题:C++ IFileOpenDialog::AddPlace方法的具体用法?C++ IFileOpenDialog::AddPlace怎么用?C++ IFileOpenDialog::AddPlace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileOpenDialog
的用法示例。
在下文中一共展示了IFileOpenDialog::AddPlace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CoCreateInstance
std::vector<std::wstring> APlayerWindow::showOpenFile()
{
HRESULT hr = S_OK;
std::vector<std::wstring> filePaths;
IFileOpenDialog *fileDlg = NULL;
hr = CoCreateInstance(CLSID_FileOpenDialog,
NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&fileDlg));
if (FAILED(hr)) return filePaths;
ON_SCOPE_EXIT([&] { fileDlg->Release(); });
IKnownFolderManager *pkfm = NULL;
hr = CoCreateInstance(CLSID_KnownFolderManager,
NULL,
CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&pkfm));
if (FAILED(hr)) return filePaths;
ON_SCOPE_EXIT([&] { pkfm->Release(); });
IKnownFolder *pKnownFolder = NULL;
hr = pkfm->GetFolder(FOLDERID_PublicMusic, &pKnownFolder);
if (FAILED(hr)) return filePaths;
ON_SCOPE_EXIT([&] { pKnownFolder->Release(); });
IShellItem *psi = NULL;
hr = pKnownFolder->GetShellItem(0, IID_PPV_ARGS(&psi));
if (FAILED(hr)) return filePaths;
ON_SCOPE_EXIT([&] { psi->Release(); });
hr = fileDlg->AddPlace(psi, FDAP_BOTTOM);
COMDLG_FILTERSPEC rgSpec[] = {
{ L"ÒôÀÖÎļþ", SupportType }
};
fileDlg->SetFileTypes(1, rgSpec);
DWORD dwOptions;
fileDlg->GetOptions(&dwOptions);
fileDlg->SetOptions(dwOptions | FOS_ALLOWMULTISELECT);
hr = fileDlg->Show(NULL);
if (SUCCEEDED(hr)) {
IShellItemArray *pRets;
hr = fileDlg->GetResults(&pRets);
if (SUCCEEDED(hr)) {
DWORD count;
pRets->GetCount(&count);
for (DWORD i = 0; i < count; i++) {
IShellItem *pRet;
LPWSTR nameBuffer;
pRets->GetItemAt(i, &pRet);
pRet->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &nameBuffer);
filePaths.push_back(std::wstring(nameBuffer));
pRet->Release();
CoTaskMemFree(nameBuffer);
}
pRets->Release();
}
}
return filePaths;
}