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


C++ IShellItem::Compare方法代码示例

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


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

示例1: v_ExecuteLibCommand

    HRESULT v_ExecuteLibCommand()
    {
        // Get the private and public save locations.
        IShellItem *psiPrivateSaveLoc;
        HRESULT hr = _plib->GetDefaultSaveFolder(DSFT_PRIVATE, IID_PPV_ARGS(&psiPrivateSaveLoc));
        if (SUCCEEDED(hr))
        {
            IShellItem *psiPublicSaveLoc;
            hr = _plib->GetDefaultSaveFolder(DSFT_PUBLIC, IID_PPV_ARGS(&psiPublicSaveLoc));
            if (SUCCEEDED(hr))
            {
                // Get the list of folders that match the specified filter.
                IShellItemArray *psiaFolders;
                hr = _plib->GetFolders(_lffFilter, IID_PPV_ARGS(&psiaFolders));
                if (SUCCEEDED(hr))
                {
                    DWORD cFolders;
                    hr = psiaFolders->GetCount(&cFolders);
                    if (SUCCEEDED(hr))
                    {
                        Output(L"Library contains %u folders:\n", cFolders);
                        for (DWORD iFolder = 0; iFolder < cFolders; iFolder++)
                        {
                            IShellItem *psiFolder;
                            if (SUCCEEDED(psiaFolders->GetItemAt(iFolder, &psiFolder)))
                            {
                                // Print each folder's name as an absolute path, suitable for parsing in the Shell Namespace (e.g SHParseDisplayName).
                                // For file system folders (the typical case), this will be the file system path of the folder.
                                PWSTR pszDisplay;
                                if (SUCCEEDED(psiFolder->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &pszDisplay)))
                                {
                                    PCWSTR pszPrefix = L"  ";
                                    int iCompare;
                                    if (S_OK == psiPrivateSaveLoc->Compare(psiFolder, SICHINT_CANONICAL | SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL, &iCompare))
                                    {
                                        pszPrefix = L"* ";
                                    }
                                    else if (S_OK == psiPublicSaveLoc->Compare(psiFolder, SICHINT_CANONICAL | SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL, &iCompare))
                                    {
                                        pszPrefix = L"# ";
                                    }

                                    Output(L"%s%s\n", pszPrefix, pszDisplay);
                                    CoTaskMemFree(pszDisplay);
                                }
                                psiFolder->Release();
                            }
                        }
                    }
                    psiaFolders->Release();
                }
                psiPublicSaveLoc->Release();
            }
            psiPrivateSaveLoc->Release();
        }
        return hr;
    }
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:57,代码来源:ShellLibraryCommandLine.cpp

示例2: PyCom_BuildPyException

// @pymethod int|PyIShellItem|Compare|Compares another shell item with this item
// @rdesc Returns 0 if items compare as equal, nonzero otherwise
PyObject *PyIShellItem::Compare(PyObject *self, PyObject *args)
{
	IShellItem *pISI = GetI(self);
	if ( pISI == NULL )
		return NULL;
	// @pyparm <o PyIShellItem>|psi||A shell item to be compared with this item
	SICHINTF hint;
	// @pyparm int|hint||shellcon.SICHINT_* value indicating how the comparison is to be performed
	PyObject *obpsi;
	IShellItem *psi;
	if ( !PyArg_ParseTuple(args, "Oi:Compare", &obpsi, &hint) )
		return NULL;
	if (!PyCom_InterfaceFromPyInstanceOrObject(obpsi, IID_IShellItem, (void **)&psi, FALSE))
		return NULL;
	HRESULT hr;
	int iOrder;
	PY_INTERFACE_PRECALL;
	hr = pISI->Compare( psi, hint, &iOrder );
	psi->Release();
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pISI, IID_IShellItem );
	return PyInt_FromLong(iOrder);
}
开发者ID:malrsrch,项目名称:pywin32,代码行数:27,代码来源:PyIShellItem.cpp

示例3: _IsItemInArray

// Determines if the provided IShellItem is listed in the array of items that the user has removed
bool _IsItemInArray(IShellItem *psi, IObjectArray *poaRemoved)
{
    bool fRet = false;
    UINT cItems;
    if (SUCCEEDED(poaRemoved->GetCount(&cItems)))
    {
        IShellItem *psiCompare;
        for (UINT i = 0; !fRet && i < cItems; i++)
        {
            if (SUCCEEDED(poaRemoved->GetAt(i, IID_PPV_ARGS(&psiCompare))))
            {
                int iOrder;
                fRet = SUCCEEDED(psiCompare->Compare(psi, SICHINT_CANONICAL, &iOrder)) && (0 == iOrder);
                psiCompare->Release();
            }
        }
    }
    return fRet;
}
开发者ID:Ippei-Murofushi,项目名称:WindowsSDK7-Samples,代码行数:20,代码来源:CustomJumpListSample.cpp


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