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


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

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


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

示例1: PyCom_BuildPyException

// @pymethod |PyIPropertyStorage|Commit|Persists the property set to its base storage
PyObject *PyIPropertyStorage::Commit(PyObject *self, PyObject *args)
{
	IPropertyStorage *pIPS = GetI(self);
	if ( pIPS == NULL )
		return NULL;
	// @pyparm int|CommitFlags||Combination of storagecon.STGC_* flags
	DWORD grfCommitFlags;
	if ( !PyArg_ParseTuple(args, "l:Commit", &grfCommitFlags) )
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIPS->Commit( grfCommitFlags );
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIPS, IID_IPropertyStorage);
	Py_INCREF(Py_None);
	return Py_None;

}
开发者ID:malrsrch,项目名称:pywin32,代码行数:21,代码来源: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::Commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。