本文整理汇总了C++中IShellLink::SetIDList方法的典型用法代码示例。如果您正苦于以下问题:C++ IShellLink::SetIDList方法的具体用法?C++ IShellLink::SetIDList怎么用?C++ IShellLink::SetIDList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IShellLink
的用法示例。
在下文中一共展示了IShellLink::SetIDList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateLnkOnDesktop
void CreateLnkOnDesktop(const LPWSTR connTitle)
{
IShellLink *SLink;
IPersistFile *PF;
HRESULT HRes;
TCHAR desktop_path[MAX_PATH] = TEXT("");
TCHAR pszFullLnkPath[MAX_PATH];
CoInitialize(NULL);
ITEMIDLIST* pidl1 = NULL;
SHGetFolderLocation(NULL, CSIDL_CONNECTIONS, NULL, 0, &pidl1);
IShellFolder *desktop, *ncfolder;
SHGetDesktopFolder(&desktop);
desktop->BindToObject(pidl1, NULL, IID_IShellFolder, (void**)&ncfolder);
IEnumIDList *items;
ncfolder->EnumObjects(NULL, SHCONTF_NONFOLDERS, &items);
ITEMIDLIST* pidl2 = NULL;
while (S_OK == items->Next(1, &pidl2, NULL))
{
STRRET sr = {STRRET_WSTR};
ncfolder->GetDisplayNameOf(pidl2, SHGDN_NORMAL, &sr);
TCHAR buf[MAX_PATH] = TEXT("");
StrRetToBuf(&sr, pidl2, buf, MAX_PATH);
if (0 == StrCmpI(buf, connTitle))
{
ITEMIDLIST* pidl3 = ILCombine(pidl1, pidl2);
HRESULT HRes = CoCreateInstance(CLSID_ShellLink, 0, CLSCTX_INPROC_SERVER, IID_IShellLink, ( LPVOID*)&SLink);
SLink->SetIDList(pidl3);
SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, 0, desktop_path);
StringCbPrintf(pszFullLnkPath, MAX_PATH * sizeof(TCHAR), TEXT("%s\\%s.lnk"), desktop_path, connTitle);
HRes = SLink->QueryInterface(IID_IPersistFile, (LPVOID*)&PF);
HRes = PF->Save((LPCOLESTR)pszFullLnkPath, TRUE);
PF->Release();
SLink->Release();
ILFree(pidl3);
ILFree(pidl2);
break;
}
ILFree(pidl2);
pidl2 = NULL;
}
ncfolder->Release();
desktop->Release();
ILFree(pidl1);
CoUninitialize();
}
示例2: OleSetOleError
// @pymethod |PyIShellLink|SetIDList|Sets the target of the link using an item id list
PyObject *PyIShellLink::SetIDList(PyObject *self, PyObject *args)
{
IShellLink *pISL = GetI(self);
if ( pISL == NULL )
return NULL;
LPITEMIDLIST pidl;
PyObject *obpidl;
// @pyparm <o PyIDL>|pidl||Absolute item id list that identifies the target
if ( !PyArg_ParseTuple(args, "O:SetIDList", &obpidl) )
return NULL;
if (!PyObject_AsPIDL( obpidl, &pidl ))
return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pISL->SetIDList( pidl );
PY_INTERFACE_POSTCALL;
PyObject_FreePIDL(pidl);
if ( FAILED(hr) )
return OleSetOleError(hr);
Py_INCREF(Py_None);
return Py_None;
}
示例3: OleSetOleError
// @pymethod |PyIShellLink|SetIDList|Sets the list of item identifiers for a shell link object.
PyObject *PyIShellLink::SetIDList(PyObject *self, PyObject *args)
{
IShellLink *pISL = GetI(self);
if ( pISL == NULL )
return NULL;
LPITEMIDLIST pidl;
PyObject *obpidl;
if ( !PyArg_ParseTuple(args, "O:SetIDList", &obpidl) )
return NULL;
BOOL bPythonIsHappy = TRUE;
if (bPythonIsHappy && !PyObject_AsPIDL( obpidl, &pidl )) bPythonIsHappy = FALSE;
if (!bPythonIsHappy) return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pISL->SetIDList( pidl );
PY_INTERFACE_POSTCALL;
PyObject_FreePIDL(pidl);
if ( FAILED(hr) )
return OleSetOleError(hr);
Py_INCREF(Py_None);
return Py_None;
}