本文整理汇总了C++中IShellItem::GetParent方法的典型用法代码示例。如果您正苦于以下问题:C++ IShellItem::GetParent方法的具体用法?C++ IShellItem::GetParent怎么用?C++ IShellItem::GetParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IShellItem
的用法示例。
在下文中一共展示了IShellItem::GetParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PyCom_BuildPyException
// @pymethod <o PyIShellItem>|PyIShellItem|GetParent|Retrieves the parent of this item
PyObject *PyIShellItem::GetParent(PyObject *self, PyObject *args)
{
IShellItem *pISI = GetI(self);
if ( pISI == NULL )
return NULL;
IShellItem *psi;
if ( !PyArg_ParseTuple(args, ":GetParent") )
return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pISI->GetParent( &psi );
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return PyCom_BuildPyException(hr, pISI, IID_IShellItem );
return PyCom_PyObjectFromIUnknown(psi, IID_IShellItem, FALSE);
}
示例2: BrowseFolderDialog
bool BrowseFolderDialog(HWND hwndOwner,TSTask::String *pDirectory,LPCTSTR pszTitle)
{
if (pDirectory==nullptr)
return false;
IFileOpenDialog *pFileOpenDialog;
HRESULT hr;
hr=::CoCreateInstance(CLSID_FileOpenDialog,nullptr,CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&pFileOpenDialog));
if (FAILED(hr))
return false;
FILEOPENDIALOGOPTIONS Options;
pFileOpenDialog->GetOptions(&Options);
pFileOpenDialog->SetOptions(Options | FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM);
if (!pDirectory->empty()) {
IShellItem *psiFolder;
hr=::SHCreateItemFromParsingName(pDirectory->c_str(),nullptr,IID_PPV_ARGS(&psiFolder));
if (SUCCEEDED(hr)) {
IShellItem *psiParent;
hr=psiFolder->GetParent(&psiParent);
if (SUCCEEDED(hr)) {
pFileOpenDialog->SetFolder(psiParent);
LPWSTR pszName;
hr=psiFolder->GetDisplayName(SIGDN_NORMALDISPLAY,&pszName);
if (SUCCEEDED(hr)) {
pFileOpenDialog->SetFileName(pszName);
::CoTaskMemFree(pszName);
}
psiParent->Release();
}
psiFolder->Release();
}
}
if (!TSTask::IsStringEmpty(pszTitle))
pFileOpenDialog->SetTitle(pszTitle);
bool fOK=false;
hr=pFileOpenDialog->Show(hwndOwner);
if (SUCCEEDED(hr)) {
LPWSTR pszPath;
IShellItem *psi;
hr=pFileOpenDialog->GetResult(&psi);
if (SUCCEEDED(hr)) {
hr=psi->GetDisplayName(SIGDN_FILESYSPATH,&pszPath);
if (SUCCEEDED(hr)) {
*pDirectory=pszPath;
fOK=true;
::CoTaskMemFree(pszPath);
}
psi->Release();
}
}
pFileOpenDialog->Release();
return fOK;
}