本文整理汇总了C++中IShellLink::GetIDList方法的典型用法代码示例。如果您正苦于以下问题:C++ IShellLink::GetIDList方法的具体用法?C++ IShellLink::GetIDList怎么用?C++ IShellLink::GetIDList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IShellLink
的用法示例。
在下文中一共展示了IShellLink::GetIDList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OleSetOleError
// @pymethod <o PyIDL>|PyIShellLink|GetIDList|Retrieves the item id list that identifies the target of the shell link.
PyObject *PyIShellLink::GetIDList(PyObject *self, PyObject *args)
{
IShellLink *pISL = GetI(self);
if ( pISL == NULL )
return NULL;
if ( !PyArg_ParseTuple(args, ":GetIDList") )
return NULL;
HRESULT hr;
LPITEMIDLIST pidl = NULL;
PY_INTERFACE_PRECALL;
hr = pISL->GetIDList( &pidl );
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return OleSetOleError(hr);
return PyObject_FromPIDL(pidl, TRUE);
}
示例2: SHGetTargetFolderIDList
// Get the target PIDL for a folder PIDL. This deals with cases where a folder
// is an alias to a real folder, folder shortcuts, etc.
STDAPI SHGetTargetFolderIDList(LPITEMIDLIST pidlFolder, LPITEMIDLIST *ppidl)
{
IShellLink *psl;
*ppidl = NULL;
HRESULT hr = SHGetUIObjectFromFullPIDL(pidlFolder, NULL, IID_IShellLink, (void**)(&psl));
if (SUCCEEDED(hr)) {
hr = psl->GetIDList(ppidl);
psl->Release();
}
// It's not a folder shortcut so get the PIDL normally.
if (FAILED(hr)) {
*ppidl = pidlFolder;
return S_OK;
}
return hr;
}
示例3: SelectFolder
bool SelectFolder(HWND hOwner)
{
BROWSEINFO info;
LPITEMIDLIST pidlist;
TCHAR path[MAX_PATH];
if (FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
{
return false;
}
info.hwndOwner = hOwner;
info.pidlRoot = NULL;
info.pszDisplayName = path;
info.lpszTitle = _T("Select a game/mod folder");
info.ulFlags = BIF_EDITBOX | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
info.lpfn = NULL;
info.lParam = 0;
info.iImage = 0;
if ((pidlist = SHBrowseForFolder(&info)) == NULL)
{
CoUninitialize();
return false;
}
/* This hellish code is from MSDN and translate shortcuts to real targets.
* God almighty, I wish Window used real symlinks.
*/
bool acquire_success = false;
bool is_link = false;
IShellFolder *psf = NULL;
LPCITEMIDLIST new_item_list;
HRESULT hr;
hr = SHBindToParent(pidlist, IID_IShellFolder, (void **)&psf, &new_item_list);
if (SUCCEEDED(hr))
{
IShellLink *psl = NULL;
hr = psf->GetUIObjectOf(hOwner, 1, &new_item_list, IID_IShellLink, NULL, (void **)&psl);
if (SUCCEEDED(hr))
{
LPITEMIDLIST new_item_list;
hr = psl->GetIDList(&new_item_list);
if (SUCCEEDED(hr))
{
is_link = true;
hr = SHGetPathFromIDList(new_item_list, method_path);
if (SUCCEEDED(hr))
{
acquire_success = true;
}
CoTaskMemFree(new_item_list);
}
psl->Release();
}
psf->Release();
}
if (!acquire_success && !is_link)
{
hr = SHGetPathFromIDList(pidlist, method_path);
if (SUCCEEDED(hr))
{
acquire_success = true;
}
}
/* That was awful. shoo, shoo, COM */
CoTaskMemFree(pidlist);
CoUninitialize();
return acquire_success;
}
示例4: GetLinkInfo
bool ShellIO::GetLinkInfo(CString fileName, LinkInfo *linkInfo, int flags)
{
IShellLink *psl;
IPersistFile *ppf;
HRESULT hRes;
bool ret = false;
hRes = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&psl);
if(SUCCEEDED(hRes))
{
hRes = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
if(SUCCEEDED(hRes))
{
hRes = ppf->Load(fileName.GetBuffer(), NULL);
if(SUCCEEDED(hRes))
{
wchar_t buf[1000];
if((flags & LI_DESCRIPTION) == LI_DESCRIPTION)
{
memset(buf, 0, sizeof(buf));
hRes = psl->GetDescription(buf, 1000);
if(SUCCEEDED(hRes) && (wcslen(buf) > 0))
{
linkInfo->description = buf;
ret = true;
}
else
{
linkInfo->description.Empty();
}
}
if((flags & LI_PATH) == LI_PATH)
{
LPITEMIDLIST pidl;
hRes = psl->GetIDList(&pidl);
if(SUCCEEDED(hRes) && pidl)
{
linkInfo->path = PIDLToString(pidl, NULL, SHGDN_FORPARSING);
ILFree(pidl);
ret = !linkInfo->path.IsEmpty();
}
else
{
linkInfo->path.Empty();
}
}
if((flags & LI_ARGUMENTS) == LI_ARGUMENTS)
{
memset(buf, 0, sizeof(buf));
hRes = psl->GetArguments(buf, 1000);
if(SUCCEEDED(hRes) && (wcslen(buf) > 0))
{
linkInfo->arguments = buf;
ret = true;
}
else
{
linkInfo->arguments.Empty();
}
}
if((flags & LI_WORKDIRECTORY) == LI_WORKDIRECTORY)
{
memset(buf, 0, sizeof(buf));
hRes = psl->GetWorkingDirectory(buf, 1000);
if(SUCCEEDED(hRes) && (wcslen(buf) > 0))
{
linkInfo->workDirectory = buf;
ret = true;
}
else
{
linkInfo->workDirectory.Empty();
}
}
if((flags & LI_ICONLOCATION) == LI_ICONLOCATION)
{
int iIcon;
memset(buf, 0, sizeof(buf));
hRes = psl->GetIconLocation(buf, 1000, &iIcon);
if(SUCCEEDED(hRes) && (wcslen(buf) > 0))
{
linkInfo->iconLocation = buf;
linkInfo->iconIndex = iIcon;
ret = true;
}
else
{
linkInfo->iconLocation.Empty();
linkInfo->iconIndex = 0;
}
}
}
ppf->Release();
}
psl->Release();
//.........这里部分代码省略.........
示例5: GetNethoodTarget
BOOL Network::GetNethoodTarget(LPCWSTR szFolder,LPWSTR szTarget,DWORD nBufferLen)
{
CStringW file(szFolder);
if (file.LastChar()!=L'\\')
file << L'\\';
file << L"desktop.ini";
WCHAR cls[300];
if (IsUnicodeSystem())
{
if (!GetPrivateProfileStringW(L".ShellClassInfo",L"CLSID2",szwEmpty,cls,300,file))
return FALSE;
}
else
{
char clsA[300];
if (!GetPrivateProfileString(".ShellClassInfo","CLSID2",szEmpty,clsA,300,W2A(file)))
return FALSE;
MultiByteToWideChar(CP_ACP,0,clsA,-1,cls,300);
}
if (wcscmp(cls,L"{0AFACED1-E828-11D1-9187-B532F1E9575D}")!=0)
return FALSE; // Folder shortcut
IShellLink* psl;
if (!SUCCEEDED(CoCreateInstance(CLSID_ShellLink,NULL,CLSCTX_INPROC_SERVER,IID_IShellLink,(void**)&psl)))
return FALSE;
IPersistFile* ppf;
if (!SUCCEEDED(psl->QueryInterface(IID_IPersistFile,(void**)&ppf)))
{
psl->Release();
return FALSE;
}
IShellFolder* psf;
if (!SUCCEEDED(SHGetDesktopFolder(&psf)))
{
ppf->Release();
psl->Release();
return FALSE;
}
file=szFolder;
if (file.LastChar()!=L'\\')
file << L'\\';
file << L"target.lnk";
BOOL bRet=FALSE;
if (SUCCEEDED(ppf->Load(file,0)))
{
LPITEMIDLIST il;
if (SUCCEEDED(psl->GetIDList(&il)))
{
STRRET str;
if (SUCCEEDED(psf->GetDisplayNameOf(il,SHGDN_FORPARSING,&str)))
{
if (ShellFunctions::StrRetToStr(str,il,szTarget,nBufferLen))
bRet=2;
}
else
{
SHDESCRIPTIONID di;
if (SUCCEEDED(SHGetDataFromIDList(psf,il,SHGDFIL_DESCRIPTIONID,&di,sizeof(SHDESCRIPTIONID))))
{
if (di.clsid==CLSID_NetworkPlaces)
{
if (SUCCEEDED(psf->GetDisplayNameOf(il,SHGDN_FORPARSING,&str)))
{
if (ShellFunctions::StrRetToStr(str,il,szTarget,nBufferLen))
bRet=szTarget[0]=='\\' && szTarget[1]=='\\';
}
}
}
}
CoTaskMemFree(il);
}
}
psf->Release();
ppf->Release();
psl->Release();
return bRet;
}