本文整理汇总了C++中IShellItemArray类的典型用法代码示例。如果您正苦于以下问题:C++ IShellItemArray类的具体用法?C++ IShellItemArray怎么用?C++ IShellItemArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IShellItemArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetI
// @pymethod |PyIShellItemArray|GetPropertyDescriptionList|Description of GetPropertyDescriptionList.
PyObject *PyIShellItemArray::GetPropertyDescriptionList(PyObject *self, PyObject *args)
{
IShellItemArray *pISIA = GetI(self);
if ( pISIA == NULL )
return NULL;
PROPERTYKEY keyType;
PyObject *obkeyType;
// @pyparm <o PyREFPROPERTYKEY>|keyType||Description for keyType
// @pyparm <o PyIID>|riid||Description for riid
PyObject *obriid;
IID riid;
void *pv;
if ( !PyArg_ParseTuple(args, "OO:GetPropertyDescriptionList", &obkeyType, &obriid) )
return NULL;
BOOL bPythonIsHappy = TRUE;
if (bPythonIsHappy && !PyObject_AsSHCOLUMNID(obkeyType, &keyType)) bPythonIsHappy = FALSE;
if (bPythonIsHappy && !PyWinObject_AsIID(obriid, &riid)) bPythonIsHappy = FALSE;
if (!bPythonIsHappy) return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pISIA->GetPropertyDescriptionList( keyType, riid, &pv );
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return PyCom_BuildPyException(hr, pISIA, IID_IShellItemArray );
return PyCom_PyObjectFromIUnknown((IUnknown *)pv, riid, FALSE);
}
示例2: 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;
}
示例3: v_ExecuteLibCommand
HRESULT v_ExecuteLibCommand()
{
// Get the private and public save locations.
IShellItem *psiPrivateSaveLoc;
HRESULT hr = _plib->GetDefaultSaveFolder(DSFT_PRIVATE, IID_PPV_ARGS(&psiPrivateSaveLoc));
if (SUCCEEDED(hr))
{
IShellItem *psiPublicSaveLoc;
hr = _plib->GetDefaultSaveFolder(DSFT_PUBLIC, IID_PPV_ARGS(&psiPublicSaveLoc));
if (SUCCEEDED(hr))
{
// Get the list of folders that match the specified filter.
IShellItemArray *psiaFolders;
hr = _plib->GetFolders(_lffFilter, IID_PPV_ARGS(&psiaFolders));
if (SUCCEEDED(hr))
{
DWORD cFolders;
hr = psiaFolders->GetCount(&cFolders);
if (SUCCEEDED(hr))
{
Output(L"Library contains %u folders:\n", cFolders);
for (DWORD iFolder = 0; iFolder < cFolders; iFolder++)
{
IShellItem *psiFolder;
if (SUCCEEDED(psiaFolders->GetItemAt(iFolder, &psiFolder)))
{
// Print each folder's name as an absolute path, suitable for parsing in the Shell Namespace (e.g SHParseDisplayName).
// For file system folders (the typical case), this will be the file system path of the folder.
PWSTR pszDisplay;
if (SUCCEEDED(psiFolder->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszDisplay)))
{
PCWSTR pszPrefix = L" ";
int iCompare;
if (S_OK == psiPrivateSaveLoc->Compare(psiFolder, SICHINT_CANONICAL | SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL, &iCompare))
{
pszPrefix = L"* ";
}
else if (S_OK == psiPublicSaveLoc->Compare(psiFolder, SICHINT_CANONICAL | SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL, &iCompare))
{
pszPrefix = L"# ";
}
Output(L"%s%s\n", pszPrefix, pszDisplay);
CoTaskMemFree(pszDisplay);
}
psiFolder->Release();
}
}
}
psiaFolders->Release();
}
psiPublicSaveLoc->Release();
}
psiPrivateSaveLoc->Release();
}
return hr;
}
示例4: fileOpenDialog
extern "C" LXCWIN_API HRESULT fileOpenDialog(HWND hWnd, DWORD *count, LPWSTR **result) {
*result = NULL;
HRESULT hr = S_OK;
CoInitialize(nullptr);
IFileOpenDialog *pfd = NULL;
hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd));
if (SUCCEEDED(hr)) {
// set default folder to "My Documents"
IShellItem *psiDocuments = NULL;
hr = SHCreateItemInKnownFolder(FOLDERID_Documents, 0, NULL,
IID_PPV_ARGS(&psiDocuments));
if (SUCCEEDED(hr)) {
hr = pfd->SetDefaultFolder(psiDocuments);
psiDocuments->Release();
}
// dialog title
pfd->SetTitle(L"Select files to share");
// allow multiselect, restrict to real files
DWORD dwOptions;
hr = pfd->GetOptions(&dwOptions);
if (SUCCEEDED(hr)) {
// ideally, allow selecting folders as well as files, but IFileDialog does not support this :(
pfd->SetOptions(dwOptions | FOS_ALLOWMULTISELECT | FOS_FORCEFILESYSTEM); // | FOS_PICKFOLDERS
}
// do not limit to certain file types
// show the open file dialog
hr = pfd->Show(hWnd);
if (SUCCEEDED(hr)) {
IShellItemArray *psiaResults;
hr = pfd->GetResults(&psiaResults);
if (SUCCEEDED(hr)) {
hr = psiaResults->GetCount(count);
if (SUCCEEDED(hr)) {
*result = (LPWSTR*)calloc(*count, sizeof(LPWSTR));
if (*result != NULL) {
for (DWORD i = 0; i < *count; i++) {
IShellItem *resultItem = NULL;
hr = psiaResults->GetItemAt(i, &resultItem);
if (SUCCEEDED(hr)) {
resultItem->GetDisplayName(SIGDN_FILESYSPATH, &((*result)[i]));
resultItem->Release();
}
}
// paths now contains selected files
}
}
psiaResults->Release();
}
}
pfd->Release();
}
return hr;
}
示例5: OnFileOk
STDMETHODIMP COpenFileListener::OnFileOk(IFileDialog* pfd)
{
IShellItemArray *psiaResults;
IFileDialogCustomize *pfdc;
HRESULT hr;
IFileOpenDialog *fod;
FILEINFO fileinfoTmp = {0};
DWORD choice;
fileinfoTmp.parentList = pFInfoList;
hr = pfd->QueryInterface(IID_PPV_ARGS(&fod));
if(SUCCEEDED(hr)) {
hr = fod->GetSelectedItems(&psiaResults);
if (SUCCEEDED(hr)) {
DWORD fileCount;
IShellItem *isi;
LPWSTR pwsz = NULL;
psiaResults->GetCount(&fileCount);
for(DWORD i=0;i<fileCount;i++) {
psiaResults->GetItemAt(i,&isi);
isi->GetDisplayName(SIGDN_FILESYSPATH,&pwsz);
isi->Release();
fileinfoTmp.szFilename = pwsz;
pFInfoList->fInfos.push_back(fileinfoTmp);
CoTaskMemFree(pwsz);
}
psiaResults->Release();
}
fod->Release();
}
hr = pfd->QueryInterface(IID_PPV_ARGS(&pfdc));
if(SUCCEEDED(hr)) {
hr = pfdc->GetSelectedControlItem(FDIALOG_OPENCHOICES,&choice);
if(SUCCEEDED(hr)) {
if(choice==FDIALOG_CHOICE_REPARENT) {
pFInfoList->uiCmdOpts = CMD_REPARENT;
}
else if(choice==FDIALOG_CHOICE_ALLHASHES) {
pFInfoList->uiCmdOpts = CMD_ALLHASHES;
}
else if(choice==FDIALOG_CHOICE_BSD) {
pFInfoList->uiCmdOpts = CMD_FORCE_BSD;
}
}
pfdc->Release();
}
return S_OK;
}
示例6: ReportSelectedItemsFromSite
void ReportSelectedItemsFromSite(IUnknown *punkSite)
{
IShellItemArray *psia;
HRESULT hr = GetSelectionFromSite(punkSite, TRUE, &psia);
if (SUCCEEDED(hr))
{
ReportSelectedItems(punkSite, psia);
psia->Release();
}
}
示例7: ReportSelectedItemsFromSite
void ReportSelectedItemsFromSite(IUnknown *punkSite)
{
if (selected_string) {
delete[] selected_string;
selected_string = NULL;
}
IShellItemArray *psia;
HRESULT hr = GetSelectionFromSite(punkSite, TRUE, &psia);
if (SUCCEEDED(hr)) {
ReportSelectedItems(punkSite, psia);
psia->Release();
}
}
示例8: wmain
int wmain()
{
// File dialog drag and drop feature requires OLE
HRESULT hr = OleInitialize(NULL);
if (SUCCEEDED(hr))
{
ISearchFolderItemFactory *pSearchFolderItemFactory;
hr = CoCreateInstance(CLSID_SearchFolderItemFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pSearchFolderItemFactory));
if (SUCCEEDED(hr))
{
IShellItemArray *psiaScope;
hr = CreateScope(&psiaScope);
if (SUCCEEDED(hr))
{
hr = pSearchFolderItemFactory->SetScope(psiaScope);
if (SUCCEEDED(hr))
{
// Sets the display name of the search
hr = pSearchFolderItemFactory->SetDisplayName(L"Sample Query");
if (SUCCEEDED(hr))
{
ICondition* pCondition;
hr = GetCondition(&pCondition);
if (SUCCEEDED(hr))
{
// Sets the condition for pSearchFolderItemFactory
hr = pSearchFolderItemFactory->SetCondition(pCondition);
if (SUCCEEDED(hr))
{
// This retrieves an IShellItem of the search. It is a virtual child of the desktop.
IShellItem* pShellItemSearch;
hr = pSearchFolderItemFactory->GetShellItem(IID_PPV_ARGS(&pShellItemSearch));
if (SUCCEEDED(hr))
{
OpenCommonFileDialogTo(pShellItemSearch);
pShellItemSearch->Release();
}
}
pCondition->Release();
}
}
}
psiaScope->Release();
}
pSearchFolderItemFactory->Release();
}
OleUninitialize();
}
return 0;
}
示例9: SHCreateItemFromIDList
// Populates item. It is the responsibility of the caller to call item->Release()
// if the return value indicates success
HRESULT ComposerShellMenu::GetShellItem(IShellItem ** item, PBOOLEAN isFile)
{
HRESULT hr = E_FAIL;
*item = NULL;
if (m_Folder)
{
hr = SHCreateItemFromIDList(m_Folder, IID_PPV_ARGS(item));
}
else if (m_Data)
{
IShellItemArray *itemArray = NULL;
hr = SHCreateShellItemArrayFromDataObject(m_Data, IID_PPV_ARGS(&itemArray));
if (SUCCEEDED(hr))
{
DWORD count = 0;
hr = itemArray->GetCount(&count);
if (SUCCEEDED(hr))
{
if (1 == count)
{
hr = itemArray->GetItemAt(0, item);
}
else
{
hr = E_FAIL;
}
}
itemArray->Release();
itemArray = NULL;
}
}
if (SUCCEEDED(hr))
{
hr = IsShellItemValid(*item, false, isFile);
if (FAILED(hr))
{
(*item)->Release();
*item = NULL;
}
}
return hr;
}
示例10: p
std::vector<fs::path> open_file_dialog::get_paths()
{
IShellItemArray *items = NULL;
dlg_->GetResults(&items);
if (items == NULL)
{
return std::vector<fs::path>();
}
DWORD count;
items->GetCount(&count);
std::vector<fs::path> paths;
for (DWORD i = 0; i < count; i++)
{
IShellItem* item = NULL;
items->GetItemAt(i, &item);
PWSTR path = NULL;
HRESULT res = item->GetDisplayName(SIGDN_FILESYSPATH, &path);
if (res != S_OK)
{
LOG(warning) << "Could not get display name from path: " << std::hex << res;
continue;
}
fs::path p(path);
paths.push_back(p);
CoTaskMemFree(path);
item->Release();
}
items->Release();
return paths;
}
示例11: GetSelectedItems
BOOL GetSelectedItems(IFileDialog *fd, vector<Wstr> *res)
{
IFolderView2 *fv = NULL;
if (FAILED(IUnknown_QueryService(fd, SID_SFolderView, IID_PPV_ARGS(&fv)))) return FALSE;
scope_defer([&](){ fv->Release(); });
IShellItemArray *sia = NULL;
if (FAILED(fv->GetSelection(TRUE, &sia))) return FALSE;
scope_defer([&](){ sia->Release(); });
DWORD num = 0;
if (FAILED(sia->GetCount(&num))) return FALSE;
for (DWORD i=0; i < num; i++) {
IShellItem *si = NULL;
if (FAILED(sia->GetItemAt(i, &si))) return FALSE;
scope_defer([&](){ si->Release(); });
// LPITEMIDLIST idl;
// DWORD val = 0;
// if (SUCCEEDED(::SHGetIDListFromObject(si, &idl))) {
// PITEMID_CHILD ic = ILFindLastID(idl);
// HRESULT hr = fv->GetSelectionState(ic, &val);
// DBG("hr=%x val=%x\n", hr, val);
// }
PWSTR path = NULL;
if (FAILED(si->GetDisplayName(SIGDN_FILESYSPATH, &path))) continue;
scope_defer([&](){ ::CoTaskMemFree(path); });
res->push_back(path);
DBGW(L"path=%s\n", path);
}
return TRUE;
}
示例12: showDirDialog
QStringList showDirDialog(IFileOpenDialog* pDialog, QWidget* parent)
{
Q_ASSERT(pDialog != NULL);
QStringList Result;
if (parent == NULL)
parent = QApplication::activeWindow();
HWND hwndParent = parent ? parent->window()->winId() : NULL;
HRESULT HResult = pDialog->Show(hwndParent);
if (SUCCEEDED(HResult))
{
// Что-то было выбрано.
IShellItemArray* pShellItemArray;
HResult = pDialog->GetResults(&pShellItemArray);
if (SUCCEEDED(HResult))
{
DWORD ItemsCount;
HResult = pShellItemArray->GetCount(&ItemsCount);
if (SUCCEEDED(HResult))
{
IShellItem* pItem;
for (DWORD i = 0; i < ItemsCount; ++i)
{
HResult = pShellItemArray->GetItemAt(i, &pItem);
if (SUCCEEDED(HResult))
{
wchar_t* lpwName;
HResult = pItem->GetDisplayName(SIGDN_FILESYSPATH, &lpwName);
if (SUCCEEDED(HResult))
{
Result.append(QString::fromWCharArray(lpwName));
CoTaskMemFree(lpwName);
}
else {
qWarning("IShellItem::GetDisplayName error: %s.",
qPrintable(GetSystemErrorString(HResult)));
}
pItem->Release();
}
else {
qWarning("IShellItemArray::GetItemAt(%lu, ...) error: %s.",
i, qPrintable(GetSystemErrorString(HResult)));
}
}
pShellItemArray->Release();
}
else {
qWarning("IShellItemArray::GetCount error: %s",
qPrintable(GetSystemErrorString(HResult)));
}
}
else {
qWarning("IFileOpenDialog::GetResults error: %s",
qPrintable(GetSystemErrorString(HResult)));
}
}
else {
if (HResult == HRESULT_FROM_WIN32(ERROR_CANCELLED)) {
// Пользователь ничего не выбрал.
}
else {
qWarning("IFileOpenDialog::Show error: %s",
qPrintable(GetSystemErrorString(HResult)));
}
}
return Result;
}
示例13: NFD_OpenDialogMultiple
nfdresult_t NFD_OpenDialogMultiple( const nfdchar_t *filterList,
const nfdchar_t *defaultPath,
nfdpathset_t *outPaths )
{
nfdresult_t nfdResult = NFD_ERROR;
// Init COM library.
HRESULT result = ::CoInitializeEx(NULL,
::COINIT_APARTMENTTHREADED |
::COINIT_DISABLE_OLE1DDE );
if ( !SUCCEEDED(result))
{
NFDi_SetError("Could not initialize COM.");
return NFD_ERROR;
}
::IFileOpenDialog *fileOpenDialog(NULL);
// Create dialog
result = ::CoCreateInstance(::CLSID_FileOpenDialog, NULL,
CLSCTX_ALL, ::IID_IFileOpenDialog,
reinterpret_cast<void**>(&fileOpenDialog) );
if ( !SUCCEEDED(result) )
{
NFDi_SetError("Could not create dialog.");
goto end;
}
// Build the filter list
if ( !AddFiltersToDialog( fileOpenDialog, filterList ) )
{
goto end;
}
// Set the default path
if ( !SetDefaultPath( fileOpenDialog, defaultPath ) )
{
goto end;
}
// Set a flag for multiple options
DWORD dwFlags;
result = fileOpenDialog->GetOptions(&dwFlags);
if ( !SUCCEEDED(result) )
{
NFDi_SetError("Could not get options.");
goto end;
}
result = fileOpenDialog->SetOptions(dwFlags | FOS_ALLOWMULTISELECT);
if ( !SUCCEEDED(result) )
{
NFDi_SetError("Could not set options.");
goto end;
}
// Show the dialog.
result = fileOpenDialog->Show(NULL);
if ( SUCCEEDED(result) )
{
IShellItemArray *shellItems;
result = fileOpenDialog->GetResults( &shellItems );
if ( !SUCCEEDED(result) )
{
NFDi_SetError("Could not get shell items.");
goto end;
}
if ( AllocPathSet( shellItems, outPaths ) == NFD_ERROR )
{
goto end;
}
shellItems->Release();
nfdResult = NFD_OKAY;
}
else if (result == HRESULT_FROM_WIN32(ERROR_CANCELLED) )
{
nfdResult = NFD_CANCEL;
}
else
{
NFDi_SetError("File dialog box show failed.");
nfdResult = NFD_ERROR;
}
end:
::CoUninitialize();
return nfdResult;
}
示例14: assert_r
bool OsShell::deleteItems(const std::vector<std::wstring>& items, bool moveToTrash, void * parentWindow)
{
ComInitializer comInitializer;
assert_r(parentWindow);
std::vector<ITEMIDLIST*> idLists;
for (auto& path: items)
{
__unaligned ITEMIDLIST* idl = ILCreateFromPathW(path.c_str());
if (!idl)
{
for (auto& pid : idLists)
ILFree(pid);
qInfo() << "ILCreateFromPathW" << "failed for path" << QString::fromWCharArray(path.c_str());
return false;
}
idLists.push_back(idl);
assert_r(idLists.back());
}
IShellItemArray * iArray = 0;
HRESULT result = SHCreateShellItemArrayFromIDLists((UINT)idLists.size(), (LPCITEMIDLIST*)idLists.data(), &iArray);
// Freeing memory
for (auto& pid: idLists)
ILFree(pid);
idLists.clear();
if (!SUCCEEDED(result) || !iArray)
{
qInfo() << "SHCreateShellItemArrayFromIDLists failed";
return false;
}
IFileOperation * iOperation = 0;
result = CoCreateInstance(CLSID_FileOperation, 0, CLSCTX_ALL, IID_IFileOperation, (void**)&iOperation);
if (!SUCCEEDED(result) || !iOperation)
{
qInfo() << "CoCreateInstance(CLSID_FileOperation, 0, CLSCTX_ALL, IID_IFileOperation, (void**)&iOperation) failed";
return false;
}
result = iOperation->DeleteItems(iArray);
if (!SUCCEEDED(result))
{
qInfo() << "DeleteItems failed";
}
else
{
if (moveToTrash)
{
result = iOperation->SetOperationFlags(FOF_ALLOWUNDO);
}
else
result = iOperation->SetOperationFlags(FOF_WANTNUKEWARNING);
if (!SUCCEEDED(result))
qInfo() << "SetOperationFlags failed";
result = iOperation->SetOwnerWindow((HWND) parentWindow);
if (!SUCCEEDED(result))
qInfo() << "SetOwnerWindow failed";
result = iOperation->PerformOperations();
if (!SUCCEEDED(result) && result != COPYENGINE_E_USER_CANCELLED)
{
qInfo() << "PerformOperations failed";
if (result == COPYENGINE_E_REQUIRES_ELEVATION)
qInfo() << "Elevation required";
}
else
result = S_OK;
}
iOperation->Release();
iArray->Release();
return SUCCEEDED(result);
}
示例15: openBrowseDialogCore
void openBrowseDialogCore(FileDialogType type, const Path& defaultPath, const String& filterList,
Vector<Path>& paths, AsyncOp& returnValue)
{
// Init COM library.
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
IFileDialog* fileDialog = nullptr;
UINT32 dialogType = ((UINT32)type & (UINT32)FileDialogType::TypeMask);
bool isOpenDialog = dialogType == (UINT32)FileDialogType::OpenFile || dialogType == (UINT32)FileDialogType::OpenFolder;
// Create dialog
IID classId = isOpenDialog ? CLSID_FileOpenDialog : CLSID_FileSaveDialog;
CoCreateInstance(classId, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&fileDialog));
addFiltersToDialog(fileDialog, filterList);
setDefaultPath(fileDialog, defaultPath);
// Apply multiselect flags
bool isMultiselect = false;
if (isOpenDialog)
{
if (dialogType == (UINT32)FileDialogType::OpenFile)
{
if (((UINT32)type & (UINT32)FileDialogType::Multiselect) != 0)
{
DWORD dwFlags;
fileDialog->GetOptions(&dwFlags);
fileDialog->SetOptions(dwFlags | FOS_ALLOWMULTISELECT);
isMultiselect = true;
}
}
else
{
DWORD dwFlags;
fileDialog->GetOptions(&dwFlags);
fileDialog->SetOptions(dwFlags | FOS_PICKFOLDERS);
}
}
// Show the dialog
bool finalResult = false;
// Need to enable all windows, otherwise when the browse dialog closes the active window will become some
// background window
Win32Window::_enableAllWindows();
if (SUCCEEDED(fileDialog->Show(nullptr)))
{
if (isMultiselect)
{
// Get file names
IFileOpenDialog* fileOpenDialog;
fileDialog->QueryInterface(IID_IFileOpenDialog, (void**)&fileOpenDialog);
IShellItemArray* shellItems = nullptr;
fileOpenDialog->GetResults(&shellItems);
getPaths(shellItems, paths);
shellItems->Release();
fileOpenDialog->Release();
}
else
{
// Get the file name
IShellItem* shellItem = nullptr;
fileDialog->GetResult(&shellItem);
LPWSTR filePath = nullptr;
shellItem->GetDisplayName(SIGDN_FILESYSPATH, &filePath);
paths.push_back((Path)UTF8::fromWide(WString(filePath)));
CoTaskMemFree(filePath);
shellItem->Release();
}
finalResult = true;
}
// Restore modal window state (before we enabled all windows)
Win32Window::_restoreModalWindows();
CoUninitialize();
returnValue._completeOperation(finalResult);
}