当前位置: 首页>>代码示例>>C++>>正文


C++ IShellLink::SetIDList方法代码示例

本文整理汇总了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();
}
开发者ID:nezhelskoy,项目名称:VPNConnectionSetup,代码行数:53,代码来源:main.cpp

示例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;
}
开发者ID:DavidGuben,项目名称:rcbplayspokemon,代码行数:25,代码来源:PyIShellLink.cpp

示例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;
}
开发者ID:locsic,项目名称:Law-Enforcement-Scripts,代码行数:25,代码来源:PyIShellLink.cpp


注:本文中的IShellLink::SetIDList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。