2002-05-14 23:50:56 +02:00
|
|
|
/*
|
2008-10-11 13:30:08 +02:00
|
|
|
* Comcat implementation
|
2002-05-14 23:50:56 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 2002 John K. Hohm
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-05-14 23:50:56 +02:00
|
|
|
*/
|
|
|
|
|
2002-05-20 00:27:41 +02:00
|
|
|
#include <string.h>
|
2008-10-11 13:30:08 +02:00
|
|
|
#include <stdarg.h>
|
2002-05-14 23:50:56 +02:00
|
|
|
|
2008-10-11 13:30:08 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "comcat.h"
|
2012-11-26 15:20:48 +01:00
|
|
|
#include "compobj_private.h"
|
|
|
|
|
2002-05-14 23:50:56 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
|
|
|
|
2011-06-21 10:38:53 +02:00
|
|
|
static const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl;
|
|
|
|
static const ICatInformationVtbl COMCAT_ICatInformation_Vtbl;
|
|
|
|
|
2008-10-11 13:30:08 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2011-06-21 10:38:53 +02:00
|
|
|
ICatRegister ICatRegister_iface;
|
|
|
|
ICatInformation ICatInformation_iface;
|
2008-10-11 13:30:08 +02:00
|
|
|
} ComCatMgrImpl;
|
2002-05-20 00:27:41 +02:00
|
|
|
|
2011-06-21 10:38:53 +02:00
|
|
|
/* static ComCatMgr instance */
|
|
|
|
static ComCatMgrImpl COMCAT_ComCatMgr =
|
|
|
|
{
|
|
|
|
{ &COMCAT_ICatRegister_Vtbl },
|
|
|
|
{ &COMCAT_ICatInformation_Vtbl }
|
|
|
|
};
|
|
|
|
|
2013-12-06 13:05:09 +01:00
|
|
|
struct class_categories
|
|
|
|
{
|
|
|
|
ULONG size; /* total length, including structure itself */
|
|
|
|
ULONG impl_offset;
|
|
|
|
ULONG req_offset;
|
2002-06-02 23:25:08 +02:00
|
|
|
};
|
|
|
|
|
2013-12-06 13:05:28 +01:00
|
|
|
static HRESULT EnumCATEGORYINFO_Construct(LCID lcid, IEnumCATEGORYINFO **ret);
|
|
|
|
static HRESULT CLSIDEnumGUID_Construct(struct class_categories *class_categories, IEnumCLSID **ret);
|
|
|
|
static HRESULT CATIDEnumGUID_Construct(REFCLSID rclsid, LPCWSTR impl_req, IEnumCATID **ret);
|
2008-10-11 13:30:08 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* File-scope string constants
|
|
|
|
*/
|
2020-09-17 10:20:24 +02:00
|
|
|
static const WCHAR comcat_keyname[] = L"Component Categories";
|
|
|
|
static const WCHAR impl_keyname[] = L"Implemented Categories";
|
|
|
|
static const WCHAR req_keyname[] = L"Required Categories";
|
2008-10-11 13:14:44 +02:00
|
|
|
|
2008-10-11 13:30:08 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_RegisterClassCategories
|
|
|
|
*/
|
|
|
|
static HRESULT COMCAT_RegisterClassCategories(
|
|
|
|
REFCLSID rclsid,
|
|
|
|
LPCWSTR type,
|
|
|
|
ULONG cCategories,
|
|
|
|
const CATID *rgcatid)
|
|
|
|
{
|
2013-12-06 13:04:43 +01:00
|
|
|
WCHAR keyname[CHARS_IN_GUID];
|
2008-10-11 13:30:08 +02:00
|
|
|
HRESULT res;
|
|
|
|
HKEY clsid_key, class_key, type_key;
|
|
|
|
|
|
|
|
if (cCategories && rgcatid == NULL) return E_POINTER;
|
|
|
|
|
|
|
|
/* Format the class key name. */
|
2013-12-06 13:04:43 +01:00
|
|
|
res = StringFromGUID2(rclsid, keyname, CHARS_IN_GUID);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (FAILED(res)) return res;
|
|
|
|
|
|
|
|
/* Create (or open) the CLSID key. */
|
2020-09-17 10:20:24 +02:00
|
|
|
res = create_classes_key(HKEY_CLASSES_ROOT, L"CLSID", KEY_READ|KEY_WRITE, &clsid_key);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (res != ERROR_SUCCESS) return E_FAIL;
|
|
|
|
|
|
|
|
/* Create (or open) the class key. */
|
2012-11-26 15:20:48 +01:00
|
|
|
res = create_classes_key(clsid_key, keyname, KEY_READ|KEY_WRITE, &class_key);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (res == ERROR_SUCCESS) {
|
|
|
|
/* Create (or open) the category type key. */
|
2012-11-26 15:20:48 +01:00
|
|
|
res = create_classes_key(class_key, type, KEY_READ|KEY_WRITE, &type_key);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (res == ERROR_SUCCESS) {
|
|
|
|
for (; cCategories; --cCategories, ++rgcatid) {
|
|
|
|
HKEY key;
|
|
|
|
|
|
|
|
/* Format the category key name. */
|
2013-12-06 13:04:43 +01:00
|
|
|
res = StringFromGUID2(rgcatid, keyname, CHARS_IN_GUID);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (FAILED(res)) continue;
|
|
|
|
|
|
|
|
/* Do the register. */
|
2012-11-26 15:20:48 +01:00
|
|
|
res = create_classes_key(type_key, keyname, KEY_READ|KEY_WRITE, &key);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (res == ERROR_SUCCESS) RegCloseKey(key);
|
|
|
|
}
|
|
|
|
res = S_OK;
|
|
|
|
} else res = E_FAIL;
|
|
|
|
RegCloseKey(class_key);
|
|
|
|
} else res = E_FAIL;
|
|
|
|
RegCloseKey(clsid_key);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_UnRegisterClassCategories
|
|
|
|
*/
|
|
|
|
static HRESULT COMCAT_UnRegisterClassCategories(
|
|
|
|
REFCLSID rclsid,
|
|
|
|
LPCWSTR type,
|
|
|
|
ULONG cCategories,
|
|
|
|
const CATID *rgcatid)
|
|
|
|
{
|
2020-11-26 22:20:04 +01:00
|
|
|
WCHAR keyname[68] = L"CLSID\\";
|
2008-10-11 13:30:08 +02:00
|
|
|
HRESULT res;
|
|
|
|
HKEY type_key;
|
|
|
|
|
|
|
|
if (cCategories && rgcatid == NULL) return E_POINTER;
|
|
|
|
|
|
|
|
/* Format the class category type key name. */
|
2013-12-06 13:04:43 +01:00
|
|
|
res = StringFromGUID2(rclsid, keyname + 6, CHARS_IN_GUID);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (FAILED(res)) return res;
|
|
|
|
keyname[44] = '\\';
|
|
|
|
lstrcpyW(keyname + 45, type);
|
|
|
|
|
|
|
|
/* Open the class category type key. */
|
2012-11-26 15:20:48 +01:00
|
|
|
res = open_classes_key(HKEY_CLASSES_ROOT, keyname, KEY_READ|KEY_WRITE, &type_key);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (res != ERROR_SUCCESS) return E_FAIL;
|
|
|
|
|
|
|
|
for (; cCategories; --cCategories, ++rgcatid) {
|
|
|
|
/* Format the category key name. */
|
2013-12-06 13:04:43 +01:00
|
|
|
res = StringFromGUID2(rgcatid, keyname, CHARS_IN_GUID);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (FAILED(res)) continue;
|
|
|
|
|
|
|
|
/* Do the unregister. */
|
|
|
|
RegDeleteKeyW(type_key, keyname);
|
|
|
|
}
|
|
|
|
RegCloseKey(type_key);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_GetCategoryDesc
|
|
|
|
*/
|
|
|
|
static HRESULT COMCAT_GetCategoryDesc(HKEY key, LCID lcid, PWCHAR pszDesc,
|
|
|
|
ULONG buf_wchars)
|
|
|
|
{
|
|
|
|
WCHAR valname[5];
|
|
|
|
HRESULT res;
|
|
|
|
DWORD type, size = (buf_wchars - 1) * sizeof(WCHAR);
|
|
|
|
|
|
|
|
if (pszDesc == NULL) return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* FIXME: lcid comparisons are more complex than this! */
|
2020-09-17 10:20:24 +02:00
|
|
|
wsprintfW(valname, L"%lX", lcid);
|
2008-10-11 13:30:08 +02:00
|
|
|
res = RegQueryValueExW(key, valname, 0, &type, (LPBYTE)pszDesc, &size);
|
|
|
|
if (res != ERROR_SUCCESS || type != REG_SZ) {
|
|
|
|
FIXME("Simplified lcid comparison\n");
|
|
|
|
return CAT_E_NODESCRIPTION;
|
|
|
|
}
|
2008-11-05 23:04:10 +01:00
|
|
|
pszDesc[size / sizeof(WCHAR)] = 0;
|
2008-10-11 13:30:08 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_PrepareClassCategories
|
|
|
|
*/
|
|
|
|
static struct class_categories *COMCAT_PrepareClassCategories(
|
|
|
|
ULONG impl_count, const CATID *impl_catids, ULONG req_count, const CATID *req_catids)
|
|
|
|
{
|
|
|
|
struct class_categories *categories;
|
|
|
|
WCHAR *strings;
|
2013-12-06 13:05:09 +01:00
|
|
|
ULONG size;
|
2008-10-11 13:30:08 +02:00
|
|
|
|
2013-12-06 13:05:09 +01:00
|
|
|
size = sizeof(struct class_categories) + ((impl_count + req_count)*CHARS_IN_GUID + 2)*sizeof(WCHAR);
|
|
|
|
categories = HeapAlloc(GetProcessHeap(), 0, size);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (categories == NULL) return categories;
|
|
|
|
|
2013-12-06 13:05:09 +01:00
|
|
|
categories->size = size;
|
|
|
|
categories->impl_offset = sizeof(struct class_categories);
|
|
|
|
categories->req_offset = categories->impl_offset + (impl_count*CHARS_IN_GUID + 1)*sizeof(WCHAR);
|
|
|
|
|
2008-10-11 13:30:08 +02:00
|
|
|
strings = (WCHAR *)(categories + 1);
|
|
|
|
while (impl_count--) {
|
2013-12-06 13:04:43 +01:00
|
|
|
StringFromGUID2(impl_catids++, strings, CHARS_IN_GUID);
|
|
|
|
strings += CHARS_IN_GUID;
|
2008-10-11 13:30:08 +02:00
|
|
|
}
|
|
|
|
*strings++ = 0;
|
|
|
|
|
|
|
|
while (req_count--) {
|
2013-12-06 13:04:43 +01:00
|
|
|
StringFromGUID2(req_catids++, strings, CHARS_IN_GUID);
|
|
|
|
strings += CHARS_IN_GUID;
|
2008-10-11 13:30:08 +02:00
|
|
|
}
|
|
|
|
*strings++ = 0;
|
|
|
|
|
|
|
|
return categories;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_IsClassOfCategories
|
|
|
|
*/
|
|
|
|
static HRESULT COMCAT_IsClassOfCategories(
|
|
|
|
HKEY key,
|
|
|
|
struct class_categories const* categories)
|
|
|
|
{
|
2013-12-06 13:05:09 +01:00
|
|
|
const WCHAR *impl_strings, *req_strings;
|
2008-10-11 13:30:08 +02:00
|
|
|
HKEY subkey;
|
|
|
|
HRESULT res;
|
|
|
|
DWORD index;
|
|
|
|
LPCWSTR string;
|
|
|
|
|
2013-12-06 13:05:09 +01:00
|
|
|
impl_strings = (WCHAR*)((BYTE*)categories + categories->impl_offset);
|
|
|
|
req_strings = (WCHAR*)((BYTE*)categories + categories->req_offset);
|
|
|
|
|
2008-10-11 13:30:08 +02:00
|
|
|
/* Check that every given category is implemented by class. */
|
2013-12-06 13:05:09 +01:00
|
|
|
if (*impl_strings) {
|
2012-11-26 15:20:48 +01:00
|
|
|
res = open_classes_key(key, impl_keyname, KEY_READ, &subkey);
|
2010-05-01 01:03:05 +02:00
|
|
|
if (res != ERROR_SUCCESS) return S_FALSE;
|
2013-12-06 13:05:09 +01:00
|
|
|
for (string = impl_strings; *string; string += CHARS_IN_GUID) {
|
2010-05-01 01:03:05 +02:00
|
|
|
HKEY catkey;
|
2015-11-27 12:26:16 +01:00
|
|
|
res = open_classes_key(subkey, string, READ_CONTROL, &catkey);
|
2010-05-01 01:03:05 +02:00
|
|
|
if (res != ERROR_SUCCESS) {
|
|
|
|
RegCloseKey(subkey);
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
RegCloseKey(catkey);
|
2008-10-11 13:30:08 +02:00
|
|
|
}
|
2010-05-01 01:03:05 +02:00
|
|
|
RegCloseKey(subkey);
|
2008-10-11 13:30:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that all categories required by class are given. */
|
2012-11-26 15:20:48 +01:00
|
|
|
res = open_classes_key(key, req_keyname, KEY_READ, &subkey);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (res == ERROR_SUCCESS) {
|
|
|
|
for (index = 0; ; ++index) {
|
2013-12-06 13:04:43 +01:00
|
|
|
WCHAR keyname[CHARS_IN_GUID];
|
|
|
|
DWORD size = CHARS_IN_GUID;
|
2008-10-11 13:30:08 +02:00
|
|
|
|
|
|
|
res = RegEnumKeyExW(subkey, index, keyname, &size,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) break;
|
2013-12-06 13:04:43 +01:00
|
|
|
if (size != CHARS_IN_GUID-1) continue; /* bogus catid in registry */
|
2013-12-06 13:05:09 +01:00
|
|
|
for (string = req_strings; *string; string += CHARS_IN_GUID)
|
2019-06-17 09:36:46 +02:00
|
|
|
if (!wcsicmp(string, keyname)) break;
|
2008-10-11 13:30:08 +02:00
|
|
|
if (!*string) {
|
|
|
|
RegCloseKey(subkey);
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey(subkey);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatRegister_QueryInterface
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatRegister_QueryInterface(
|
|
|
|
LPCATREGISTER iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
2009-06-09 13:00:30 +02:00
|
|
|
TRACE("%s\n",debugstr_guid(riid));
|
2008-10-11 13:30:08 +02:00
|
|
|
|
|
|
|
if (ppvObj == NULL) return E_POINTER;
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_ICatRegister)) {
|
|
|
|
*ppvObj = iface;
|
2011-06-21 10:38:53 +02:00
|
|
|
ICatRegister_AddRef(iface);
|
2008-10-11 13:30:08 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_ICatInformation)) {
|
2011-06-21 10:38:53 +02:00
|
|
|
*ppvObj = &COMCAT_ComCatMgr.ICatInformation_iface;
|
|
|
|
ICatRegister_AddRef(iface);
|
2008-10-11 13:30:08 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatRegister_AddRef
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI COMCAT_ICatRegister_AddRef(LPCATREGISTER iface)
|
|
|
|
{
|
|
|
|
return 2; /* non-heap based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatRegister_Release
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI COMCAT_ICatRegister_Release(LPCATREGISTER iface)
|
|
|
|
{
|
|
|
|
return 1; /* non-heap based object */
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatRegister_RegisterCategories
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatRegister_RegisterCategories(
|
|
|
|
LPCATREGISTER iface,
|
|
|
|
ULONG cCategories,
|
|
|
|
CATEGORYINFO *rgci)
|
|
|
|
{
|
|
|
|
HKEY comcat_key;
|
|
|
|
HRESULT res;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (cCategories && rgci == NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
/* Create (or open) the component categories key. */
|
2012-11-26 15:20:48 +01:00
|
|
|
res = create_classes_key(HKEY_CLASSES_ROOT, comcat_keyname, KEY_READ|KEY_WRITE, &comcat_key);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (res != ERROR_SUCCESS) return E_FAIL;
|
|
|
|
|
2020-09-17 10:20:24 +02:00
|
|
|
for (; cCategories; --cCategories, ++rgci)
|
|
|
|
{
|
2013-12-06 13:04:43 +01:00
|
|
|
WCHAR keyname[CHARS_IN_GUID];
|
2008-10-11 13:30:08 +02:00
|
|
|
WCHAR valname[9];
|
|
|
|
HKEY cat_key;
|
|
|
|
|
|
|
|
/* Create (or open) the key for this category. */
|
2013-12-06 13:04:43 +01:00
|
|
|
if (!StringFromGUID2(&rgci->catid, keyname, CHARS_IN_GUID)) continue;
|
2012-11-26 15:20:48 +01:00
|
|
|
res = create_classes_key(comcat_key, keyname, KEY_READ|KEY_WRITE, &cat_key);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (res != ERROR_SUCCESS) continue;
|
|
|
|
|
|
|
|
/* Set the value for this locale's description. */
|
2020-09-17 10:20:24 +02:00
|
|
|
wsprintfW(valname, L"%lX", rgci->lcid);
|
2013-09-25 10:39:19 +02:00
|
|
|
RegSetValueExW(cat_key, valname, 0, REG_SZ, (const BYTE*)rgci->szDescription,
|
2008-10-11 13:30:08 +02:00
|
|
|
(lstrlenW(rgci->szDescription) + 1) * sizeof(WCHAR));
|
|
|
|
|
|
|
|
RegCloseKey(cat_key);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(comcat_key);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatRegister_UnRegisterCategories
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterCategories(
|
|
|
|
LPCATREGISTER iface,
|
|
|
|
ULONG cCategories,
|
|
|
|
CATID *rgcatid)
|
|
|
|
{
|
|
|
|
HKEY comcat_key;
|
|
|
|
HRESULT res;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (cCategories && rgcatid == NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
/* Open the component categories key. */
|
2012-11-26 15:20:48 +01:00
|
|
|
res = open_classes_key(HKEY_CLASSES_ROOT, comcat_keyname, KEY_READ|KEY_WRITE, &comcat_key);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (res != ERROR_SUCCESS) return E_FAIL;
|
|
|
|
|
|
|
|
for (; cCategories; --cCategories, ++rgcatid) {
|
2013-12-06 13:04:43 +01:00
|
|
|
WCHAR keyname[CHARS_IN_GUID];
|
2008-10-11 13:30:08 +02:00
|
|
|
|
|
|
|
/* Delete the key for this category. */
|
2013-12-06 13:04:43 +01:00
|
|
|
if (!StringFromGUID2(rgcatid, keyname, CHARS_IN_GUID)) continue;
|
2008-10-11 13:30:08 +02:00
|
|
|
RegDeleteKeyW(comcat_key, keyname);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(comcat_key);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatRegister_RegisterClassImplCategories
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassImplCategories(
|
|
|
|
LPCATREGISTER iface,
|
|
|
|
REFCLSID rclsid,
|
|
|
|
ULONG cCategories,
|
|
|
|
CATID *rgcatid)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
return COMCAT_RegisterClassCategories(
|
|
|
|
rclsid, impl_keyname, cCategories, rgcatid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatRegister_UnRegisterClassImplCategories
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassImplCategories(
|
|
|
|
LPCATREGISTER iface,
|
|
|
|
REFCLSID rclsid,
|
|
|
|
ULONG cCategories,
|
|
|
|
CATID *rgcatid)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
return COMCAT_UnRegisterClassCategories(
|
|
|
|
rclsid, impl_keyname, cCategories, rgcatid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatRegister_RegisterClassReqCategories
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassReqCategories(
|
|
|
|
LPCATREGISTER iface,
|
|
|
|
REFCLSID rclsid,
|
|
|
|
ULONG cCategories,
|
|
|
|
CATID *rgcatid)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
return COMCAT_RegisterClassCategories(
|
|
|
|
rclsid, req_keyname, cCategories, rgcatid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatRegister_UnRegisterClassReqCategories
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassReqCategories(
|
|
|
|
LPCATREGISTER iface,
|
|
|
|
REFCLSID rclsid,
|
|
|
|
ULONG cCategories,
|
|
|
|
CATID *rgcatid)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
return COMCAT_UnRegisterClassCategories(
|
|
|
|
rclsid, req_keyname, cCategories, rgcatid);
|
|
|
|
}
|
|
|
|
|
2002-05-14 23:50:56 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatInformation_QueryInterface
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatInformation_QueryInterface(
|
|
|
|
LPCATINFORMATION iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
2011-06-21 10:38:53 +02:00
|
|
|
return ICatRegister_QueryInterface(&COMCAT_ComCatMgr.ICatRegister_iface, riid, ppvObj);
|
2002-05-14 23:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatInformation_AddRef
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI COMCAT_ICatInformation_AddRef(LPCATINFORMATION iface)
|
|
|
|
{
|
2011-06-21 10:38:53 +02:00
|
|
|
return ICatRegister_AddRef(&COMCAT_ComCatMgr.ICatRegister_iface);
|
2002-05-14 23:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatInformation_Release
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI COMCAT_ICatInformation_Release(LPCATINFORMATION iface)
|
|
|
|
{
|
2011-06-21 10:38:53 +02:00
|
|
|
return ICatRegister_Release(&COMCAT_ComCatMgr.ICatRegister_iface);
|
2002-05-14 23:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatInformation_EnumCategories
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatInformation_EnumCategories(
|
|
|
|
LPCATINFORMATION iface,
|
|
|
|
LCID lcid,
|
2011-07-13 14:22:05 +02:00
|
|
|
IEnumCATEGORYINFO **ppenumCatInfo)
|
2002-05-14 23:50:56 +02:00
|
|
|
{
|
2002-05-20 00:27:41 +02:00
|
|
|
TRACE("\n");
|
2002-05-14 23:50:56 +02:00
|
|
|
|
2008-10-11 11:57:39 +02:00
|
|
|
if (ppenumCatInfo == NULL) return E_POINTER;
|
2002-05-20 00:27:41 +02:00
|
|
|
|
2013-12-06 13:05:28 +01:00
|
|
|
return EnumCATEGORYINFO_Construct(lcid, ppenumCatInfo);
|
2002-05-14 23:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatInformation_GetCategoryDesc
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatInformation_GetCategoryDesc(
|
|
|
|
LPCATINFORMATION iface,
|
|
|
|
REFCATID rcatid,
|
|
|
|
LCID lcid,
|
|
|
|
PWCHAR *ppszDesc)
|
|
|
|
{
|
2020-11-26 22:20:04 +01:00
|
|
|
WCHAR keyname[60] = L"Component Categories\\";
|
2002-05-20 00:27:41 +02:00
|
|
|
HKEY key;
|
|
|
|
HRESULT res;
|
2002-05-14 23:50:56 +02:00
|
|
|
|
2022-02-08 21:09:20 +01:00
|
|
|
TRACE("CATID: %s LCID: %lx\n",debugstr_guid(rcatid), lcid);
|
2002-05-20 00:27:41 +02:00
|
|
|
|
|
|
|
if (rcatid == NULL || ppszDesc == NULL) return E_INVALIDARG;
|
|
|
|
|
|
|
|
/* Open the key for this category. */
|
2013-12-06 13:04:43 +01:00
|
|
|
if (!StringFromGUID2(rcatid, keyname + 21, CHARS_IN_GUID)) return E_FAIL;
|
2012-11-26 15:20:48 +01:00
|
|
|
res = open_classes_key(HKEY_CLASSES_ROOT, keyname, KEY_READ, &key);
|
2002-05-20 00:27:41 +02:00
|
|
|
if (res != ERROR_SUCCESS) return CAT_E_CATIDNOEXIST;
|
|
|
|
|
|
|
|
/* Allocate a sensible amount of memory for the description. */
|
2008-11-05 23:04:10 +01:00
|
|
|
*ppszDesc = CoTaskMemAlloc(128 * sizeof(WCHAR));
|
2002-05-20 00:27:41 +02:00
|
|
|
if (*ppszDesc == NULL) {
|
|
|
|
RegCloseKey(key);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the description, and make sure it's null terminated. */
|
|
|
|
res = COMCAT_GetCategoryDesc(key, lcid, *ppszDesc, 128);
|
|
|
|
RegCloseKey(key);
|
|
|
|
if (FAILED(res)) {
|
|
|
|
CoTaskMemFree(*ppszDesc);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2002-05-14 23:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatInformation_EnumClassesOfCategories
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatInformation_EnumClassesOfCategories(
|
|
|
|
LPCATINFORMATION iface,
|
|
|
|
ULONG cImplemented,
|
|
|
|
CATID *rgcatidImpl,
|
|
|
|
ULONG cRequired,
|
|
|
|
CATID *rgcatidReq,
|
|
|
|
LPENUMCLSID *ppenumCLSID)
|
|
|
|
{
|
2002-06-02 23:25:08 +02:00
|
|
|
struct class_categories *categories;
|
2013-12-06 13:05:28 +01:00
|
|
|
HRESULT hr;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
2002-05-14 23:50:56 +02:00
|
|
|
|
2008-10-11 13:30:08 +02:00
|
|
|
if (cImplemented == (ULONG)-1)
|
2006-07-13 21:16:59 +02:00
|
|
|
cImplemented = 0;
|
2008-10-11 13:30:08 +02:00
|
|
|
if (cRequired == (ULONG)-1)
|
2006-07-13 21:16:59 +02:00
|
|
|
cRequired = 0;
|
2008-10-11 13:30:08 +02:00
|
|
|
|
2008-10-11 11:57:39 +02:00
|
|
|
if (ppenumCLSID == NULL ||
|
2002-06-02 23:25:08 +02:00
|
|
|
(cImplemented && rgcatidImpl == NULL) ||
|
|
|
|
(cRequired && rgcatidReq == NULL)) return E_POINTER;
|
|
|
|
|
|
|
|
categories = COMCAT_PrepareClassCategories(cImplemented, rgcatidImpl,
|
|
|
|
cRequired, rgcatidReq);
|
|
|
|
if (categories == NULL) return E_OUTOFMEMORY;
|
2013-12-06 13:05:28 +01:00
|
|
|
|
|
|
|
hr = CLSIDEnumGUID_Construct(categories, ppenumCLSID);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2002-06-02 23:25:08 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, categories);
|
2013-12-06 13:05:28 +01:00
|
|
|
return hr;
|
2002-06-02 23:25:08 +02:00
|
|
|
}
|
2013-12-06 13:05:28 +01:00
|
|
|
|
|
|
|
return hr;
|
2002-05-14 23:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatInformation_IsClassOfCategories
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatInformation_IsClassOfCategories(
|
|
|
|
LPCATINFORMATION iface,
|
|
|
|
REFCLSID rclsid,
|
|
|
|
ULONG cImplemented,
|
|
|
|
CATID *rgcatidImpl,
|
|
|
|
ULONG cRequired,
|
|
|
|
CATID *rgcatidReq)
|
|
|
|
{
|
2020-11-26 22:20:04 +01:00
|
|
|
WCHAR keyname[45] = L"CLSID\\";
|
2002-06-02 23:25:08 +02:00
|
|
|
HRESULT res;
|
|
|
|
struct class_categories *categories;
|
|
|
|
HKEY key;
|
|
|
|
|
2012-01-10 22:29:40 +01:00
|
|
|
if (TRACE_ON(ole)) {
|
2002-06-02 23:25:08 +02:00
|
|
|
ULONG count;
|
2022-02-08 21:09:20 +01:00
|
|
|
TRACE("CLSID: %s Implemented %lu\n",debugstr_guid(rclsid),cImplemented);
|
2002-06-02 23:25:08 +02:00
|
|
|
for (count = 0; count < cImplemented; ++count)
|
2009-06-09 13:00:30 +02:00
|
|
|
TRACE(" %s\n",debugstr_guid(&rgcatidImpl[count]));
|
2022-02-08 21:09:20 +01:00
|
|
|
TRACE("Required %lu\n",cRequired);
|
2002-06-02 23:25:08 +02:00
|
|
|
for (count = 0; count < cRequired; ++count)
|
2009-06-09 13:00:30 +02:00
|
|
|
TRACE(" %s\n",debugstr_guid(&rgcatidReq[count]));
|
2002-06-02 23:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((cImplemented && rgcatidImpl == NULL) ||
|
|
|
|
(cRequired && rgcatidReq == NULL)) return E_POINTER;
|
|
|
|
|
2013-12-06 13:04:43 +01:00
|
|
|
res = StringFromGUID2(rclsid, keyname + 6, CHARS_IN_GUID);
|
2002-06-02 23:25:08 +02:00
|
|
|
if (FAILED(res)) return res;
|
|
|
|
|
|
|
|
categories = COMCAT_PrepareClassCategories(cImplemented, rgcatidImpl,
|
|
|
|
cRequired, rgcatidReq);
|
|
|
|
if (categories == NULL) return E_OUTOFMEMORY;
|
|
|
|
|
2012-11-26 15:20:48 +01:00
|
|
|
res = open_classes_key(HKEY_CLASSES_ROOT, keyname, KEY_READ, &key);
|
2002-06-02 23:25:08 +02:00
|
|
|
if (res == ERROR_SUCCESS) {
|
|
|
|
res = COMCAT_IsClassOfCategories(key, categories);
|
|
|
|
RegCloseKey(key);
|
|
|
|
} else res = S_FALSE;
|
2002-05-14 23:50:56 +02:00
|
|
|
|
2002-06-02 23:25:08 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, categories);
|
|
|
|
|
|
|
|
return res;
|
2002-05-14 23:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatInformation_EnumImplCategoriesOfClass
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatInformation_EnumImplCategoriesOfClass(
|
|
|
|
LPCATINFORMATION iface,
|
|
|
|
REFCLSID rclsid,
|
|
|
|
LPENUMCATID *ppenumCATID)
|
|
|
|
{
|
2009-06-09 13:00:30 +02:00
|
|
|
TRACE("%s\n",debugstr_guid(rclsid));
|
2002-06-02 23:25:08 +02:00
|
|
|
|
2008-10-11 11:57:39 +02:00
|
|
|
if (rclsid == NULL || ppenumCATID == NULL)
|
2002-06-02 23:25:08 +02:00
|
|
|
return E_POINTER;
|
2002-05-14 23:50:56 +02:00
|
|
|
|
2020-09-17 10:20:24 +02:00
|
|
|
return CATIDEnumGUID_Construct(rclsid, L"\\Implemented Categories", ppenumCATID);
|
2002-05-14 23:50:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatInformation_EnumReqCategoriesOfClass
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI COMCAT_ICatInformation_EnumReqCategoriesOfClass(
|
|
|
|
LPCATINFORMATION iface,
|
|
|
|
REFCLSID rclsid,
|
|
|
|
LPENUMCATID *ppenumCATID)
|
|
|
|
{
|
2009-06-09 13:00:30 +02:00
|
|
|
TRACE("%s\n",debugstr_guid(rclsid));
|
2002-05-14 23:50:56 +02:00
|
|
|
|
2008-10-11 11:57:39 +02:00
|
|
|
if (rclsid == NULL || ppenumCATID == NULL)
|
2002-06-02 23:25:08 +02:00
|
|
|
return E_POINTER;
|
|
|
|
|
2020-09-17 10:20:24 +02:00
|
|
|
return CATIDEnumGUID_Construct(rclsid, L"\\Required Categories", ppenumCATID);
|
2002-05-14 23:50:56 +02:00
|
|
|
}
|
|
|
|
|
2008-10-11 13:30:08 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatRegister_Vtbl
|
|
|
|
*/
|
|
|
|
static const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl =
|
|
|
|
{
|
|
|
|
COMCAT_ICatRegister_QueryInterface,
|
|
|
|
COMCAT_ICatRegister_AddRef,
|
|
|
|
COMCAT_ICatRegister_Release,
|
|
|
|
COMCAT_ICatRegister_RegisterCategories,
|
|
|
|
COMCAT_ICatRegister_UnRegisterCategories,
|
|
|
|
COMCAT_ICatRegister_RegisterClassImplCategories,
|
|
|
|
COMCAT_ICatRegister_UnRegisterClassImplCategories,
|
|
|
|
COMCAT_ICatRegister_RegisterClassReqCategories,
|
|
|
|
COMCAT_ICatRegister_UnRegisterClassReqCategories
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-05-14 23:50:56 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* COMCAT_ICatInformation_Vtbl
|
|
|
|
*/
|
2008-10-11 13:30:08 +02:00
|
|
|
static const ICatInformationVtbl COMCAT_ICatInformation_Vtbl =
|
2002-05-14 23:50:56 +02:00
|
|
|
{
|
|
|
|
COMCAT_ICatInformation_QueryInterface,
|
|
|
|
COMCAT_ICatInformation_AddRef,
|
|
|
|
COMCAT_ICatInformation_Release,
|
|
|
|
COMCAT_ICatInformation_EnumCategories,
|
|
|
|
COMCAT_ICatInformation_GetCategoryDesc,
|
|
|
|
COMCAT_ICatInformation_EnumClassesOfCategories,
|
|
|
|
COMCAT_ICatInformation_IsClassOfCategories,
|
|
|
|
COMCAT_ICatInformation_EnumImplCategoriesOfClass,
|
|
|
|
COMCAT_ICatInformation_EnumReqCategoriesOfClass
|
|
|
|
};
|
2002-05-20 00:27:41 +02:00
|
|
|
|
2017-02-21 13:20:18 +01:00
|
|
|
HRESULT WINAPI ComCat_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter, REFIID riid, void **ppvObj)
|
2008-10-11 13:30:08 +02:00
|
|
|
{
|
|
|
|
HRESULT res;
|
2009-06-09 13:00:30 +02:00
|
|
|
TRACE("%s\n",debugstr_guid(riid));
|
2008-10-11 13:30:08 +02:00
|
|
|
|
|
|
|
if (ppvObj == NULL) return E_POINTER;
|
|
|
|
|
|
|
|
/* Don't support aggregation (Windows doesn't) */
|
|
|
|
if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2011-06-21 10:38:53 +02:00
|
|
|
res = ICatRegister_QueryInterface(&COMCAT_ComCatMgr.ICatRegister_iface, riid, ppvObj);
|
2008-10-11 13:30:08 +02:00
|
|
|
if (SUCCEEDED(res)) {
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
2002-05-20 00:27:41 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* IEnumCATEGORYINFO implementation
|
|
|
|
*
|
|
|
|
* This implementation is not thread-safe. The manager itself is, but
|
|
|
|
* I can't imagine a valid use of an enumerator in several threads.
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2011-07-13 14:22:05 +02:00
|
|
|
IEnumCATEGORYINFO IEnumCATEGORYINFO_iface;
|
2005-07-11 15:21:17 +02:00
|
|
|
LONG ref;
|
2002-05-20 00:27:41 +02:00
|
|
|
LCID lcid;
|
|
|
|
HKEY key;
|
|
|
|
DWORD next_index;
|
|
|
|
} IEnumCATEGORYINFOImpl;
|
|
|
|
|
2011-07-13 14:22:05 +02:00
|
|
|
static inline IEnumCATEGORYINFOImpl *impl_from_IEnumCATEGORYINFO(IEnumCATEGORYINFO *iface)
|
2002-05-20 00:27:41 +02:00
|
|
|
{
|
2011-07-13 14:22:05 +02:00
|
|
|
return CONTAINING_RECORD(iface, IEnumCATEGORYINFOImpl, IEnumCATEGORYINFO_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_AddRef(IEnumCATEGORYINFO *iface)
|
|
|
|
{
|
|
|
|
IEnumCATEGORYINFOImpl *This = impl_from_IEnumCATEGORYINFO(iface);
|
2005-01-10 13:25:29 +01:00
|
|
|
|
2002-05-20 00:27:41 +02:00
|
|
|
TRACE("\n");
|
|
|
|
|
2005-01-10 13:25:29 +01:00
|
|
|
return InterlockedIncrement(&This->ref);
|
2002-05-20 00:27:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_QueryInterface(
|
2011-07-13 14:22:05 +02:00
|
|
|
IEnumCATEGORYINFO *iface,
|
2002-05-20 00:27:41 +02:00
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
2009-06-09 13:00:30 +02:00
|
|
|
TRACE("%s\n",debugstr_guid(riid));
|
2002-05-20 00:27:41 +02:00
|
|
|
|
2008-10-11 11:57:39 +02:00
|
|
|
if (ppvObj == NULL) return E_POINTER;
|
2002-05-20 00:27:41 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IEnumCATEGORYINFO))
|
|
|
|
{
|
2009-02-11 10:48:38 +01:00
|
|
|
*ppvObj = iface;
|
2002-05-20 00:27:41 +02:00
|
|
|
COMCAT_IEnumCATEGORYINFO_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2011-07-13 14:22:05 +02:00
|
|
|
static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_Release(IEnumCATEGORYINFO *iface)
|
2002-05-20 00:27:41 +02:00
|
|
|
{
|
2011-07-13 14:22:05 +02:00
|
|
|
IEnumCATEGORYINFOImpl *This = impl_from_IEnumCATEGORYINFO(iface);
|
2005-01-10 13:25:29 +01:00
|
|
|
ULONG ref;
|
|
|
|
|
2002-05-20 00:27:41 +02:00
|
|
|
TRACE("\n");
|
|
|
|
|
2005-01-10 13:25:29 +01:00
|
|
|
ref = InterlockedDecrement(&This->ref);
|
|
|
|
if (ref == 0) {
|
2002-05-20 00:27:41 +02:00
|
|
|
if (This->key) RegCloseKey(This->key);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-01-10 13:25:29 +01:00
|
|
|
return ref;
|
2002-05-20 00:27:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Next(
|
2011-07-13 14:22:05 +02:00
|
|
|
IEnumCATEGORYINFO *iface,
|
2002-05-20 00:27:41 +02:00
|
|
|
ULONG celt,
|
|
|
|
CATEGORYINFO *rgelt,
|
|
|
|
ULONG *pceltFetched)
|
|
|
|
{
|
2011-07-13 14:22:05 +02:00
|
|
|
IEnumCATEGORYINFOImpl *This = impl_from_IEnumCATEGORYINFO(iface);
|
2002-05-20 00:27:41 +02:00
|
|
|
ULONG fetched = 0;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2008-10-11 11:57:39 +02:00
|
|
|
if (rgelt == NULL) return E_POINTER;
|
2002-05-20 00:27:41 +02:00
|
|
|
|
|
|
|
if (This->key) while (fetched < celt) {
|
2008-09-30 14:54:57 +02:00
|
|
|
LSTATUS res;
|
|
|
|
HRESULT hr;
|
2013-12-06 13:04:43 +01:00
|
|
|
WCHAR catid[CHARS_IN_GUID];
|
|
|
|
DWORD cName = CHARS_IN_GUID;
|
2002-05-20 00:27:41 +02:00
|
|
|
HKEY subkey;
|
|
|
|
|
|
|
|
res = RegEnumKeyExW(This->key, This->next_index, catid, &cName,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) break;
|
|
|
|
++(This->next_index);
|
|
|
|
|
2008-09-30 14:54:57 +02:00
|
|
|
hr = CLSIDFromString(catid, &rgelt->catid);
|
|
|
|
if (FAILED(hr)) continue;
|
2002-05-20 00:27:41 +02:00
|
|
|
|
2012-11-26 15:20:48 +01:00
|
|
|
res = open_classes_key(This->key, catid, KEY_READ, &subkey);
|
2002-05-20 00:27:41 +02:00
|
|
|
if (res != ERROR_SUCCESS) continue;
|
|
|
|
|
2008-09-30 14:54:57 +02:00
|
|
|
hr = COMCAT_GetCategoryDesc(subkey, This->lcid,
|
|
|
|
rgelt->szDescription, 128);
|
2002-05-20 00:27:41 +02:00
|
|
|
RegCloseKey(subkey);
|
2008-09-30 14:54:57 +02:00
|
|
|
if (FAILED(hr)) continue;
|
2002-05-20 00:27:41 +02:00
|
|
|
|
|
|
|
rgelt->lcid = This->lcid;
|
|
|
|
++fetched;
|
|
|
|
++rgelt;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pceltFetched) *pceltFetched = fetched;
|
|
|
|
return fetched == celt ? S_OK : S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Skip(
|
2011-07-13 14:22:05 +02:00
|
|
|
IEnumCATEGORYINFO *iface,
|
2002-05-20 00:27:41 +02:00
|
|
|
ULONG celt)
|
|
|
|
{
|
2011-07-13 14:22:05 +02:00
|
|
|
IEnumCATEGORYINFOImpl *This = impl_from_IEnumCATEGORYINFO(iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
2002-05-20 00:27:41 +02:00
|
|
|
|
2002-06-02 23:25:08 +02:00
|
|
|
This->next_index += celt;
|
|
|
|
/* This should return S_FALSE when there aren't celt elems to skip. */
|
|
|
|
return S_OK;
|
2002-05-20 00:27:41 +02:00
|
|
|
}
|
|
|
|
|
2011-07-13 14:22:05 +02:00
|
|
|
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Reset(IEnumCATEGORYINFO *iface)
|
2002-05-20 00:27:41 +02:00
|
|
|
{
|
2011-07-13 14:22:05 +02:00
|
|
|
IEnumCATEGORYINFOImpl *This = impl_from_IEnumCATEGORYINFO(iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
2002-05-20 00:27:41 +02:00
|
|
|
|
2002-06-02 23:25:08 +02:00
|
|
|
This->next_index = 0;
|
|
|
|
return S_OK;
|
2002-05-20 00:27:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Clone(
|
2011-07-13 14:22:05 +02:00
|
|
|
IEnumCATEGORYINFO *iface,
|
2002-05-20 00:27:41 +02:00
|
|
|
IEnumCATEGORYINFO **ppenum)
|
|
|
|
{
|
2011-07-13 14:22:05 +02:00
|
|
|
IEnumCATEGORYINFOImpl *This = impl_from_IEnumCATEGORYINFO(iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
IEnumCATEGORYINFOImpl *new_this;
|
2002-05-20 00:27:41 +02:00
|
|
|
|
2002-06-02 23:25:08 +02:00
|
|
|
TRACE("\n");
|
|
|
|
|
2008-10-11 11:57:39 +02:00
|
|
|
if (ppenum == NULL) return E_POINTER;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
2005-03-22 19:26:06 +01:00
|
|
|
new_this = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumCATEGORYINFOImpl));
|
2002-06-02 23:25:08 +02:00
|
|
|
if (new_this == NULL) return E_OUTOFMEMORY;
|
|
|
|
|
2011-07-13 14:22:05 +02:00
|
|
|
new_this->IEnumCATEGORYINFO_iface = This->IEnumCATEGORYINFO_iface;
|
2002-06-02 23:25:08 +02:00
|
|
|
new_this->ref = 1;
|
|
|
|
new_this->lcid = This->lcid;
|
|
|
|
/* FIXME: could we more efficiently use DuplicateHandle? */
|
2020-09-17 10:20:24 +02:00
|
|
|
open_classes_key(HKEY_CLASSES_ROOT, comcat_keyname, KEY_READ, &new_this->key);
|
2002-06-02 23:25:08 +02:00
|
|
|
new_this->next_index = This->next_index;
|
|
|
|
|
2011-07-13 14:22:05 +02:00
|
|
|
*ppenum = &new_this->IEnumCATEGORYINFO_iface;
|
2002-06-02 23:25:08 +02:00
|
|
|
return S_OK;
|
2002-05-20 00:27:41 +02:00
|
|
|
}
|
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
static const IEnumCATEGORYINFOVtbl COMCAT_IEnumCATEGORYINFO_Vtbl =
|
2002-05-20 00:27:41 +02:00
|
|
|
{
|
|
|
|
COMCAT_IEnumCATEGORYINFO_QueryInterface,
|
|
|
|
COMCAT_IEnumCATEGORYINFO_AddRef,
|
|
|
|
COMCAT_IEnumCATEGORYINFO_Release,
|
|
|
|
COMCAT_IEnumCATEGORYINFO_Next,
|
|
|
|
COMCAT_IEnumCATEGORYINFO_Skip,
|
|
|
|
COMCAT_IEnumCATEGORYINFO_Reset,
|
|
|
|
COMCAT_IEnumCATEGORYINFO_Clone
|
|
|
|
};
|
|
|
|
|
2013-12-06 13:05:28 +01:00
|
|
|
static HRESULT EnumCATEGORYINFO_Construct(LCID lcid, IEnumCATEGORYINFO **ret)
|
2002-05-20 00:27:41 +02:00
|
|
|
{
|
|
|
|
IEnumCATEGORYINFOImpl *This;
|
|
|
|
|
2013-12-06 13:05:28 +01:00
|
|
|
*ret = NULL;
|
|
|
|
|
2005-03-22 19:26:06 +01:00
|
|
|
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumCATEGORYINFOImpl));
|
2013-12-06 13:05:28 +01:00
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->IEnumCATEGORYINFO_iface.lpVtbl = &COMCAT_IEnumCATEGORYINFO_Vtbl;
|
|
|
|
This->ref = 1;
|
|
|
|
This->lcid = lcid;
|
2020-09-17 10:20:24 +02:00
|
|
|
open_classes_key(HKEY_CLASSES_ROOT, comcat_keyname, KEY_READ, &This->key);
|
2013-12-06 13:05:28 +01:00
|
|
|
|
|
|
|
*ret = &This->IEnumCATEGORYINFO_iface;
|
|
|
|
return S_OK;
|
2002-05-20 00:27:41 +02:00
|
|
|
}
|
|
|
|
|
2002-06-02 23:25:08 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* ClassesOfCategories IEnumCLSID (IEnumGUID) implementation
|
|
|
|
*
|
|
|
|
* This implementation is not thread-safe. The manager itself is, but
|
|
|
|
* I can't imagine a valid use of an enumerator in several threads.
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
IEnumGUID IEnumGUID_iface;
|
2005-07-11 15:21:17 +02:00
|
|
|
LONG ref;
|
2007-07-20 22:36:36 +02:00
|
|
|
struct class_categories *categories;
|
2002-06-02 23:25:08 +02:00
|
|
|
HKEY key;
|
|
|
|
DWORD next_index;
|
|
|
|
} CLSID_IEnumGUIDImpl;
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static inline CLSID_IEnumGUIDImpl *impl_from_IEnumCLSID(IEnumGUID *iface)
|
2002-06-02 23:25:08 +02:00
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
return CONTAINING_RECORD(iface, CLSID_IEnumGUIDImpl, IEnumGUID_iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static HRESULT WINAPI CLSIDEnumGUID_QueryInterface(
|
|
|
|
IEnumGUID *iface,
|
2002-06-02 23:25:08 +02:00
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
2009-06-09 13:00:30 +02:00
|
|
|
TRACE("%s\n",debugstr_guid(riid));
|
2002-06-02 23:25:08 +02:00
|
|
|
|
2008-10-11 11:57:39 +02:00
|
|
|
if (ppvObj == NULL) return E_POINTER;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IEnumGUID))
|
|
|
|
{
|
2009-02-11 10:48:38 +01:00
|
|
|
*ppvObj = iface;
|
2013-12-06 13:04:25 +01:00
|
|
|
IEnumGUID_AddRef(iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static ULONG WINAPI CLSIDEnumGUID_AddRef(IEnumGUID *iface)
|
|
|
|
{
|
|
|
|
CLSID_IEnumGUIDImpl *This = impl_from_IEnumCLSID(iface);
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI CLSIDEnumGUID_Release(IEnumGUID *iface)
|
2002-06-02 23:25:08 +02:00
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
CLSID_IEnumGUIDImpl *This = impl_from_IEnumCLSID(iface);
|
2005-01-10 13:25:29 +01:00
|
|
|
ULONG ref;
|
|
|
|
|
2002-06-02 23:25:08 +02:00
|
|
|
TRACE("\n");
|
|
|
|
|
2005-01-10 13:25:29 +01:00
|
|
|
ref = InterlockedDecrement(&This->ref);
|
|
|
|
if (ref == 0) {
|
2002-06-02 23:25:08 +02:00
|
|
|
if (This->key) RegCloseKey(This->key);
|
2009-02-11 10:48:38 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->categories);
|
2002-06-02 23:25:08 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-01-10 13:25:29 +01:00
|
|
|
return ref;
|
2002-06-02 23:25:08 +02:00
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static HRESULT WINAPI CLSIDEnumGUID_Next(
|
|
|
|
IEnumGUID *iface,
|
2002-06-02 23:25:08 +02:00
|
|
|
ULONG celt,
|
|
|
|
GUID *rgelt,
|
|
|
|
ULONG *pceltFetched)
|
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
CLSID_IEnumGUIDImpl *This = impl_from_IEnumCLSID(iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
ULONG fetched = 0;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2008-10-11 11:57:39 +02:00
|
|
|
if (rgelt == NULL) return E_POINTER;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
if (This->key) while (fetched < celt) {
|
2008-09-30 14:54:57 +02:00
|
|
|
LSTATUS res;
|
|
|
|
HRESULT hr;
|
2013-12-06 13:04:43 +01:00
|
|
|
WCHAR clsid[CHARS_IN_GUID];
|
|
|
|
DWORD cName = CHARS_IN_GUID;
|
2002-06-02 23:25:08 +02:00
|
|
|
HKEY subkey;
|
|
|
|
|
|
|
|
res = RegEnumKeyExW(This->key, This->next_index, clsid, &cName,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) break;
|
|
|
|
++(This->next_index);
|
|
|
|
|
2008-09-30 14:54:57 +02:00
|
|
|
hr = CLSIDFromString(clsid, rgelt);
|
|
|
|
if (FAILED(hr)) continue;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
2012-11-26 15:20:48 +01:00
|
|
|
res = open_classes_key(This->key, clsid, KEY_READ, &subkey);
|
2002-06-02 23:25:08 +02:00
|
|
|
if (res != ERROR_SUCCESS) continue;
|
|
|
|
|
2008-09-30 14:54:57 +02:00
|
|
|
hr = COMCAT_IsClassOfCategories(subkey, This->categories);
|
2002-06-02 23:25:08 +02:00
|
|
|
RegCloseKey(subkey);
|
2008-09-30 14:54:57 +02:00
|
|
|
if (hr != S_OK) continue;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
++fetched;
|
|
|
|
++rgelt;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pceltFetched) *pceltFetched = fetched;
|
|
|
|
return fetched == celt ? S_OK : S_FALSE;
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static HRESULT WINAPI CLSIDEnumGUID_Skip(
|
|
|
|
IEnumGUID *iface,
|
2002-06-02 23:25:08 +02:00
|
|
|
ULONG celt)
|
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
CLSID_IEnumGUIDImpl *This = impl_from_IEnumCLSID(iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
This->next_index += celt;
|
|
|
|
FIXME("Never returns S_FALSE\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static HRESULT WINAPI CLSIDEnumGUID_Reset(IEnumGUID *iface)
|
2002-06-02 23:25:08 +02:00
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
CLSID_IEnumGUIDImpl *This = impl_from_IEnumCLSID(iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
This->next_index = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static HRESULT WINAPI CLSIDEnumGUID_Clone(
|
|
|
|
IEnumGUID *iface,
|
2002-06-02 23:25:08 +02:00
|
|
|
IEnumGUID **ppenum)
|
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
CLSID_IEnumGUIDImpl *This = impl_from_IEnumCLSID(iface);
|
2013-12-06 13:05:09 +01:00
|
|
|
CLSID_IEnumGUIDImpl *cloned;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
2013-12-06 13:05:09 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, ppenum);
|
2002-06-02 23:25:08 +02:00
|
|
|
|
2008-10-11 11:57:39 +02:00
|
|
|
if (ppenum == NULL) return E_POINTER;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
2013-12-06 13:05:09 +01:00
|
|
|
*ppenum = NULL;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
2013-12-06 13:05:09 +01:00
|
|
|
cloned = HeapAlloc(GetProcessHeap(), 0, sizeof(CLSID_IEnumGUIDImpl));
|
|
|
|
if (cloned == NULL) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
cloned->IEnumGUID_iface.lpVtbl = This->IEnumGUID_iface.lpVtbl;
|
|
|
|
cloned->ref = 1;
|
|
|
|
|
|
|
|
cloned->categories = HeapAlloc(GetProcessHeap(), 0, This->categories->size);
|
|
|
|
if (cloned->categories == NULL) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, cloned);
|
2002-06-02 23:25:08 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2013-12-06 13:05:09 +01:00
|
|
|
memcpy(cloned->categories, This->categories, This->categories->size);
|
|
|
|
|
|
|
|
cloned->key = NULL;
|
2020-09-17 10:20:24 +02:00
|
|
|
open_classes_key(HKEY_CLASSES_ROOT, L"CLSID", KEY_READ, &cloned->key);
|
2013-12-06 13:05:09 +01:00
|
|
|
cloned->next_index = This->next_index;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
2013-12-06 13:05:09 +01:00
|
|
|
*ppenum = &cloned->IEnumGUID_iface;
|
2002-06-02 23:25:08 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static const IEnumGUIDVtbl CLSIDEnumGUIDVtbl =
|
2002-06-02 23:25:08 +02:00
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
CLSIDEnumGUID_QueryInterface,
|
|
|
|
CLSIDEnumGUID_AddRef,
|
|
|
|
CLSIDEnumGUID_Release,
|
|
|
|
CLSIDEnumGUID_Next,
|
|
|
|
CLSIDEnumGUID_Skip,
|
|
|
|
CLSIDEnumGUID_Reset,
|
|
|
|
CLSIDEnumGUID_Clone
|
2002-06-02 23:25:08 +02:00
|
|
|
};
|
|
|
|
|
2013-12-06 13:05:28 +01:00
|
|
|
static HRESULT CLSIDEnumGUID_Construct(struct class_categories *categories, IEnumCLSID **ret)
|
2002-06-02 23:25:08 +02:00
|
|
|
{
|
|
|
|
CLSID_IEnumGUIDImpl *This;
|
|
|
|
|
2013-12-06 13:05:28 +01:00
|
|
|
*ret = NULL;
|
|
|
|
|
2005-03-22 19:26:06 +01:00
|
|
|
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CLSID_IEnumGUIDImpl));
|
2013-12-06 13:05:28 +01:00
|
|
|
if (!This) return E_OUTOFMEMORY;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
2013-12-06 13:05:28 +01:00
|
|
|
This->IEnumGUID_iface.lpVtbl = &CLSIDEnumGUIDVtbl;
|
|
|
|
This->ref = 1;
|
|
|
|
This->categories = categories;
|
2020-09-17 10:20:24 +02:00
|
|
|
open_classes_key(HKEY_CLASSES_ROOT, L"CLSID", KEY_READ, &This->key);
|
2013-12-06 13:05:28 +01:00
|
|
|
|
|
|
|
*ret = &This->IEnumGUID_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
2002-06-02 23:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CategoriesOfClass IEnumCATID (IEnumGUID) implementation
|
|
|
|
*
|
|
|
|
* This implementation is not thread-safe. The manager itself is, but
|
|
|
|
* I can't imagine a valid use of an enumerator in several threads.
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
IEnumGUID IEnumGUID_iface;
|
2005-07-11 15:21:17 +02:00
|
|
|
LONG ref;
|
2002-06-02 23:25:08 +02:00
|
|
|
WCHAR keyname[68];
|
|
|
|
HKEY key;
|
|
|
|
DWORD next_index;
|
|
|
|
} CATID_IEnumGUIDImpl;
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static inline CATID_IEnumGUIDImpl *impl_from_IEnumCATID(IEnumGUID *iface)
|
2002-06-02 23:25:08 +02:00
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
return CONTAINING_RECORD(iface, CATID_IEnumGUIDImpl, IEnumGUID_iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static HRESULT WINAPI CATIDEnumGUID_QueryInterface(
|
|
|
|
IEnumGUID *iface,
|
2002-06-02 23:25:08 +02:00
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
2009-06-09 13:00:30 +02:00
|
|
|
TRACE("%s\n",debugstr_guid(riid));
|
2002-06-02 23:25:08 +02:00
|
|
|
|
2008-10-11 11:57:39 +02:00
|
|
|
if (ppvObj == NULL) return E_POINTER;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IEnumGUID))
|
|
|
|
{
|
2009-02-11 10:48:38 +01:00
|
|
|
*ppvObj = iface;
|
2013-12-06 13:04:25 +01:00
|
|
|
IEnumGUID_AddRef(iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static ULONG WINAPI CATIDEnumGUID_AddRef(IEnumGUID *iface)
|
|
|
|
{
|
|
|
|
CATID_IEnumGUIDImpl *This = impl_from_IEnumCATID(iface);
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI CATIDEnumGUID_Release(IEnumGUID *iface)
|
2002-06-02 23:25:08 +02:00
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
CATID_IEnumGUIDImpl *This = impl_from_IEnumCATID(iface);
|
2005-01-10 13:25:29 +01:00
|
|
|
ULONG ref;
|
|
|
|
|
2002-06-02 23:25:08 +02:00
|
|
|
TRACE("\n");
|
|
|
|
|
2005-01-10 13:25:29 +01:00
|
|
|
ref = InterlockedDecrement(&This->ref);
|
|
|
|
if (ref == 0) {
|
2002-06-02 23:25:08 +02:00
|
|
|
if (This->key) RegCloseKey(This->key);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-01-10 13:25:29 +01:00
|
|
|
return ref;
|
2002-06-02 23:25:08 +02:00
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static HRESULT WINAPI CATIDEnumGUID_Next(
|
|
|
|
IEnumGUID *iface,
|
2002-06-02 23:25:08 +02:00
|
|
|
ULONG celt,
|
|
|
|
GUID *rgelt,
|
|
|
|
ULONG *pceltFetched)
|
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
CATID_IEnumGUIDImpl *This = impl_from_IEnumCATID(iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
ULONG fetched = 0;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2008-10-11 11:57:39 +02:00
|
|
|
if (rgelt == NULL) return E_POINTER;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
if (This->key) while (fetched < celt) {
|
2008-09-30 14:54:57 +02:00
|
|
|
LSTATUS res;
|
|
|
|
HRESULT hr;
|
2013-12-06 13:04:43 +01:00
|
|
|
WCHAR catid[CHARS_IN_GUID];
|
|
|
|
DWORD cName = CHARS_IN_GUID;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
res = RegEnumKeyExW(This->key, This->next_index, catid, &cName,
|
|
|
|
NULL, NULL, NULL, NULL);
|
|
|
|
if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) break;
|
|
|
|
++(This->next_index);
|
|
|
|
|
2008-09-30 14:54:57 +02:00
|
|
|
hr = CLSIDFromString(catid, rgelt);
|
|
|
|
if (FAILED(hr)) continue;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
++fetched;
|
|
|
|
++rgelt;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pceltFetched) *pceltFetched = fetched;
|
|
|
|
return fetched == celt ? S_OK : S_FALSE;
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static HRESULT WINAPI CATIDEnumGUID_Skip(
|
|
|
|
IEnumGUID *iface,
|
2002-06-02 23:25:08 +02:00
|
|
|
ULONG celt)
|
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
CATID_IEnumGUIDImpl *This = impl_from_IEnumCATID(iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
This->next_index += celt;
|
|
|
|
FIXME("Never returns S_FALSE\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static HRESULT WINAPI CATIDEnumGUID_Reset(IEnumGUID *iface)
|
2002-06-02 23:25:08 +02:00
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
CATID_IEnumGUIDImpl *This = impl_from_IEnumCATID(iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
This->next_index = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static HRESULT WINAPI CATIDEnumGUID_Clone(
|
|
|
|
IEnumGUID *iface,
|
2002-06-02 23:25:08 +02:00
|
|
|
IEnumGUID **ppenum)
|
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
CATID_IEnumGUIDImpl *This = impl_from_IEnumCATID(iface);
|
2002-06-02 23:25:08 +02:00
|
|
|
CATID_IEnumGUIDImpl *new_this;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
2008-10-11 11:57:39 +02:00
|
|
|
if (ppenum == NULL) return E_POINTER;
|
2002-06-02 23:25:08 +02:00
|
|
|
|
2005-03-22 19:26:06 +01:00
|
|
|
new_this = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CATID_IEnumGUIDImpl));
|
2002-06-02 23:25:08 +02:00
|
|
|
if (new_this == NULL) return E_OUTOFMEMORY;
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
new_this->IEnumGUID_iface.lpVtbl = This->IEnumGUID_iface.lpVtbl;
|
2002-06-02 23:25:08 +02:00
|
|
|
new_this->ref = 1;
|
|
|
|
lstrcpyW(new_this->keyname, This->keyname);
|
|
|
|
/* FIXME: could we more efficiently use DuplicateHandle? */
|
2012-11-26 15:20:48 +01:00
|
|
|
open_classes_key(HKEY_CLASSES_ROOT, new_this->keyname, KEY_READ, &new_this->key);
|
2002-06-02 23:25:08 +02:00
|
|
|
new_this->next_index = This->next_index;
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
*ppenum = &new_this->IEnumGUID_iface;
|
2002-06-02 23:25:08 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-12-06 13:04:25 +01:00
|
|
|
static const IEnumGUIDVtbl CATIDEnumGUIDVtbl =
|
2002-06-02 23:25:08 +02:00
|
|
|
{
|
2013-12-06 13:04:25 +01:00
|
|
|
CATIDEnumGUID_QueryInterface,
|
|
|
|
CATIDEnumGUID_AddRef,
|
|
|
|
CATIDEnumGUID_Release,
|
|
|
|
CATIDEnumGUID_Next,
|
|
|
|
CATIDEnumGUID_Skip,
|
|
|
|
CATIDEnumGUID_Reset,
|
|
|
|
CATIDEnumGUID_Clone
|
2002-06-02 23:25:08 +02:00
|
|
|
};
|
|
|
|
|
2013-12-06 13:05:28 +01:00
|
|
|
static HRESULT CATIDEnumGUID_Construct(REFCLSID rclsid, LPCWSTR postfix, IEnumGUID **ret)
|
2002-06-02 23:25:08 +02:00
|
|
|
{
|
2013-12-06 13:05:28 +01:00
|
|
|
WCHAR keyname[100], clsidW[CHARS_IN_GUID];
|
2002-06-02 23:25:08 +02:00
|
|
|
CATID_IEnumGUIDImpl *This;
|
|
|
|
|
2013-12-06 13:05:28 +01:00
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CATID_IEnumGUIDImpl));
|
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
StringFromGUID2(rclsid, clsidW, CHARS_IN_GUID);
|
|
|
|
|
|
|
|
This->IEnumGUID_iface.lpVtbl = &CATIDEnumGUIDVtbl;
|
|
|
|
This->ref = 1;
|
2020-09-17 10:20:24 +02:00
|
|
|
lstrcpyW(keyname, L"CLSID\\");
|
2019-06-17 09:36:46 +02:00
|
|
|
lstrcatW(keyname, clsidW);
|
|
|
|
lstrcatW(keyname, postfix);
|
2013-12-06 13:05:28 +01:00
|
|
|
|
|
|
|
open_classes_key(HKEY_CLASSES_ROOT, keyname, KEY_READ, &This->key);
|
|
|
|
|
|
|
|
*ret = &This->IEnumGUID_iface;
|
|
|
|
return S_OK;
|
2002-06-02 23:25:08 +02:00
|
|
|
}
|