You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.5 KiB
104 lines
2.5 KiB
/*****************************************************************************\
|
|
FILE: util.cpp
|
|
|
|
DESCRIPTION:
|
|
Shared stuff that operates on all classes.
|
|
|
|
BryanSt 5/30/2000
|
|
Copyright (C) Microsoft Corp 2000-2000. All rights reserved.
|
|
\*****************************************************************************/
|
|
|
|
#include "precomp.h"
|
|
#pragma hdrstop
|
|
|
|
#include "util.h"
|
|
|
|
BOOL IUnknown_CompareCLSID(IN IUnknown * punk, IN CLSID clsid)
|
|
{
|
|
BOOL fIsEqual = FALSE;
|
|
|
|
if (punk)
|
|
{
|
|
CLSID clsidPageID;
|
|
HRESULT hr = IUnknown_GetClassID(punk, &clsidPageID);
|
|
|
|
if (SUCCEEDED(hr) && IsEqualCLSID(clsidPageID, clsid))
|
|
{
|
|
fIsEqual = TRUE;
|
|
}
|
|
}
|
|
|
|
return fIsEqual;
|
|
}
|
|
|
|
|
|
HRESULT IEnumUnknown_FindCLSID(IN IUnknown * punk, IN CLSID clsid, OUT IUnknown ** ppunkFound)
|
|
{
|
|
HRESULT hr = E_INVALIDARG;
|
|
|
|
if (punk && ppunkFound)
|
|
{
|
|
IEnumUnknown * pEnum;
|
|
|
|
*ppunkFound = NULL;
|
|
hr = punk->QueryInterface(IID_PPV_ARG(IEnumUnknown, &pEnum));
|
|
if (SUCCEEDED(hr))
|
|
{
|
|
IUnknown * punkToTry;
|
|
ULONG ulFetched;
|
|
|
|
while (SUCCEEDED(pEnum->Next(1, &punkToTry, &ulFetched)) &&
|
|
(1 == ulFetched))
|
|
{
|
|
if (IUnknown_CompareCLSID(punkToTry, clsid))
|
|
{
|
|
*ppunkFound = punkToTry;
|
|
break;
|
|
}
|
|
|
|
punkToTry->Release();
|
|
}
|
|
|
|
pEnum->Release();
|
|
}
|
|
}
|
|
|
|
return hr;
|
|
}
|
|
|
|
HRESULT GetPageByCLSID(IUnknown * punkSite, const GUID * pClsid, IPropertyBag ** ppPropertyBag)
|
|
{
|
|
HRESULT hr = E_FAIL;
|
|
|
|
*ppPropertyBag = NULL;
|
|
if (punkSite)
|
|
{
|
|
IThemeUIPages * pThemeUI;
|
|
|
|
hr = punkSite->QueryInterface(IID_PPV_ARG(IThemeUIPages, &pThemeUI));
|
|
if (SUCCEEDED(hr))
|
|
{
|
|
IEnumUnknown * pEnumUnknown;
|
|
|
|
hr = pThemeUI->GetBasePagesEnum(&pEnumUnknown);
|
|
if (SUCCEEDED(hr))
|
|
{
|
|
IUnknown * punk;
|
|
|
|
// This may not exit due to policy
|
|
hr = IEnumUnknown_FindCLSID(pEnumUnknown, *pClsid, &punk);
|
|
if (SUCCEEDED(hr))
|
|
{
|
|
hr = punk->QueryInterface(IID_PPV_ARG(IPropertyBag, ppPropertyBag));
|
|
punk->Release();
|
|
}
|
|
|
|
pEnumUnknown->Release();
|
|
}
|
|
|
|
pThemeUI->Release();
|
|
}
|
|
}
|
|
|
|
return hr;
|
|
}
|