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


C++ IPropertyStorage::WriteMultiple方法代码示例

本文整理汇总了C++中IPropertyStorage::WriteMultiple方法的典型用法代码示例。如果您正苦于以下问题:C++ IPropertyStorage::WriteMultiple方法的具体用法?C++ IPropertyStorage::WriteMultiple怎么用?C++ IPropertyStorage::WriteMultiple使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPropertyStorage的用法示例。


在下文中一共展示了IPropertyStorage::WriteMultiple方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetI

// @pymethod |PyIPropertyStorage|WriteMultiple|Creates or modifies properties in the property set
PyObject *PyIPropertyStorage::WriteMultiple(PyObject *self, PyObject *args)
{
	PyObject *ret=NULL;
	PROPSPEC *pProps = NULL;
	PROPVARIANT *pVals = NULL;
	ULONG cProps, cVals;

	IPropertyStorage *pIPS = GetI(self);
	if ( pIPS == NULL )
		return NULL;
	PyObject *obProps;
	PyObject *obValues;
	long minId = 2;
	// @pyparm (<o PROPSPEC>, ...)|props||Sequence containing names or integer ids of properties to write
	// @pyparm (<o PROPVARIANT>, ...)|values||The values for the properties.
	// @pyparm int|propidNameFirst|2|Minimum property id to be assigned to new properties specified by name
	if ( !PyArg_ParseTuple(args, "OO|l:WriteMultiple", &obProps, &obValues, &minId))
		return NULL;
	
	if (!PyWinObject_AsPROPSPECs( obProps, &pProps, &cProps))
		goto cleanup;
	if (!PyObject_AsPROPVARIANTs( obValues, &pVals, &cVals ))
		goto cleanup;

	if (cProps != cVals) {
		PyErr_SetString(PyExc_ValueError, "The parameters must be sequences of the same size");
		goto cleanup;
	}

	HRESULT hr;
	{
	PY_INTERFACE_PRECALL;
	hr = pIPS->WriteMultiple( cProps, pProps, pVals, minId );
	PY_INTERFACE_POSTCALL;
	}
	if ( FAILED(hr) )
		PyCom_BuildPyException(hr, pIPS, IID_IPropertyStorage);
	else{
		Py_INCREF(Py_None);
		ret = Py_None;
		}

cleanup:
	PyObject_FreePROPSPECs(pProps, cProps);
	PyObject_FreePROPVARIANTs(pVals, cVals);
	return ret;
}
开发者ID:malrsrch,项目名称:pywin32,代码行数:48,代码来源:PyIPropertyStorage.cpp

示例2: CreateUrl

/******************************************************************
 CreateUrl - Creates a shortcut via IUniformResourceLocatorW

*******************************************************************/
static HRESULT CreateUrl(
    __in_z LPCWSTR wzTarget,
    __in_z LPCWSTR wzShortcutPath,
    __in_z_opt LPCWSTR wzIconPath,
    __in int iconIndex
)
{
    HRESULT hr = S_OK;
    IUniformResourceLocatorW* piURL = NULL;
    IPersistFile* piPersistFile = NULL;
    IPropertySetStorage* piProperties = NULL;
    IPropertyStorage* piStorage = NULL;

    // create an internet shortcut object
    WcaLog(LOGMSG_STANDARD, "Creating IUniformResourceLocatorW shortcut '%ls' target '%ls'", wzShortcutPath, wzTarget);
    hr = ::CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_ALL, IID_IUniformResourceLocatorW, (void**)&piURL);
    ExitOnFailure(hr, "failed to create an instance of IUniformResourceLocatorW");

    // set shortcut target
    hr = piURL->SetURL(wzTarget, 0);
    ExitOnFailure2(hr, "failed to set shortcut '%ls' target '%ls'", wzShortcutPath, wzTarget);

    if (wzIconPath)
    {
        hr = piURL->QueryInterface(IID_IPropertySetStorage, (void **)&piProperties);
        ExitOnFailure1(hr, "failed to get IPropertySetStorage for shortcut '%ls'", wzShortcutPath);

        hr = piProperties->Open(FMTID_Intshcut, STGM_WRITE, &piStorage);
        ExitOnFailure1(hr, "failed to open storage for shortcut '%ls'", wzShortcutPath);

        PROPSPEC ppids[2] = { {PRSPEC_PROPID, PID_IS_ICONINDEX}, {PRSPEC_PROPID, PID_IS_ICONFILE} };
        PROPVARIANT ppvar[2];

        PropVariantInit(ppvar);
        PropVariantInit(ppvar + 1);

        ppvar[0].vt = VT_I4;
        ppvar[0].lVal = iconIndex;
        ppvar[1].vt = VT_LPWSTR;
        ppvar[1].pwszVal = (LPWSTR)wzIconPath;

        hr = piStorage->WriteMultiple(2, ppids, ppvar, 0);
        ExitOnFailure1(hr, "failed to write icon storage for shortcut '%ls'", wzShortcutPath);

        hr = piStorage->Commit(STGC_DEFAULT);
        ExitOnFailure1(hr, "failed to commit icon storage for shortcut '%ls'", wzShortcutPath);
    }

    // get an IPersistFile and save the shortcut
    hr = piURL->QueryInterface(IID_IPersistFile, (void**)&piPersistFile);
    ExitOnFailure1(hr, "failed to get IPersistFile for shortcut '%ls'", wzShortcutPath);

    hr = piPersistFile->Save(wzShortcutPath, TRUE);
    ExitOnFailure1(hr, "failed to save shortcut '%ls'", wzShortcutPath);

LExit:
    ReleaseObject(piPersistFile);
    ReleaseObject(piURL);
    ReleaseObject(piStorage);
    ReleaseObject(piProperties);

    return hr;
}
开发者ID:BMurri,项目名称:wix3,代码行数:67,代码来源:netshortcuts.cpp


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