ReactOS  0.4.14-dev-358-gbef841c
comcat.c File Reference
#include <stdio.h>
#include <initguid.h>
#include <windows.h>
#include "objbase.h"
#include "comcat.h"
#include "wine/test.h"
Include dependency graph for comcat.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define ok_ole_success(hr, func)   ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
 

Functions

static BOOL register_testentry (void)
 
static void unregister_testentry (void)
 
static void do_enum (void)
 
 START_TEST (comcat)
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file comcat.c.

◆ ok_ole_success

#define ok_ole_success (   hr,
  func 
)    ok(hr == S_OK, func " failed with error 0x%08x\n", hr)

Definition at line 32 of file comcat.c.

Function Documentation

◆ do_enum()

static void do_enum ( void  )
static

Definition at line 59 of file comcat.c.

60 {
61  HRESULT hr;
62  REFCLSID rclsid = &CLSID_StdComponentCategoriesMgr;
63  ICatInformation *pICat = (ICatInformation*)0xdeadbeef;
64  GUID the_guid[1];
65  GUID the_cat[1];
66  GUID wanted_guid;
67  ULONG fetched = -1;
68 
69  static const WCHAR szCatID[] = {
70  '{',
71  'd','e','a','d','c','a','f','e',
72  '-','0','0','0','0','-','0','0','0','0',
73  '-','0','0','0','0',
74  '-','0','0','0','0','0','0','0','0','0','0','0','0',
75  '}',0};
76  static const WCHAR szGuid[] = {
77  '{',
78  'd','e','a','d','c','a','f','e','-',
79  'b','e','e','d','-',
80  'b','e','a','d','-',
81  'd','e','a','d','-',
82  'c','a','f','e','b','e','a','d','d','e','a','d',
83  '}',0};
84 
85  IEnumCLSID *pIEnum =(IEnumCLSID*)0xdeadcafe;
86 
87  CLSIDFromString(szCatID,the_cat);
88  CLSIDFromString(szGuid,&wanted_guid);
89 
91 
92  hr = CoCreateInstance(rclsid,NULL,CLSCTX_INPROC_SERVER,
93  &IID_ICatInformation, (void **)&pICat);
94  ok_ole_success(hr, "CoCreateInstance");
95 
96  hr = ICatInformation_EnumClassesOfCategories(pICat, -1, NULL, -1, NULL,
97  &pIEnum);
98  ok_ole_success(hr,"ICatInformation_EnumClassesOfCategories");
99 
100  IEnumGUID_Release(pIEnum);
101 
102  hr = ICatInformation_EnumClassesOfCategories(pICat, 1, the_cat, -1, NULL,
103  &pIEnum);
104  ok_ole_success(hr,"ICatInformation_EnumClassesOfCategories");
105 
106  hr = IEnumGUID_Next(pIEnum,1,the_guid, &fetched);
107  ok (hr == S_FALSE,"Expected S_FALSE, got 0x%08x\n", hr);
108  ok (fetched == 0,"Fetched wrong number of guids %u\n",fetched);
109  IEnumGUID_Release(pIEnum);
110 
111  if (register_testentry())
112  {
113  hr = ICatInformation_EnumClassesOfCategories(pICat, 1, the_cat, -1, NULL, &pIEnum);
114  ok_ole_success(hr,"ICatInformation_EnumClassesOfCategories");
115 
116  hr = IEnumGUID_Next(pIEnum,1,the_guid, &fetched);
117  ok (hr == S_OK,"Expected S_OK, got 0x%08x\n", hr);
118  ok (fetched == 1,"Fetched wrong number of guids %u\n",fetched);
119  ok (IsEqualGUID(the_guid,&wanted_guid),"Guids do not match\n");
120 
121  IEnumGUID_Release(pIEnum);
123  }
124  else skip( "Could not register the test category\n" );
125 
126  ICatInformation_Release(pICat);
127 
128  OleUninitialize();
129 }
HRESULT hr
Definition: shlfolder.c:183
#define REFCLSID
Definition: guiddef.h:117
#define S_FALSE
Definition: winerror.h:2357
#define IEnumCLSID
Definition: comcat.idl:39
smooth NULL
Definition: ftsmooth.c:416
static void unregister_testentry(void)
Definition: comcat.c:49
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static BOOL register_testentry(void)
Definition: comcat.c:34
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:169
#define S_OK
Definition: intsafe.h:59
static const WCHAR szGuid[]
Definition: rtlstr.c:1892
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define skip(...)
Definition: atltest.h:64
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2338
unsigned int ULONG
Definition: retypes.h:1
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:230
#define ok_ole_success(hr, func)
Definition: comcat.c:32

Referenced by START_TEST().

◆ register_testentry()

static BOOL register_testentry ( void  )
static

Definition at line 34 of file comcat.c.

35 {
36  HKEY hkey = 0, hkey2 = 0;
37  DWORD ret;
38 
39  ret = RegCreateKeyA(HKEY_CLASSES_ROOT,"CLSID\\{deadcafe-beed-bead-dead-cafebeaddead}", &hkey);
40  if (!ret) ret = RegSetValueA(hkey,NULL,REG_SZ,"ComCat Test key",16);
41  if (!ret) ret = RegCreateKeyA(hkey,
42  "Implemented Categories\\{deadcafe-0000-0000-0000-000000000000}",
43  &hkey2);
44  RegCloseKey(hkey);
45  RegCloseKey(hkey2);
46  return !ret;
47 }
LONG WINAPI RegSetValueA(HKEY hKeyOriginal, LPCSTR lpSubKey, DWORD dwType, LPCSTR lpData, DWORD cbData)
Definition: reg.c:4968
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1177
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define REG_SZ
Definition: layer.c:22

Referenced by do_enum().

◆ START_TEST()

START_TEST ( comcat  )

Definition at line 132 of file comcat.c.

133 {
134  do_enum();
135 }
static void do_enum(void)
Definition: comcat.c:59

◆ unregister_testentry()

static void unregister_testentry ( void  )
static

Definition at line 49 of file comcat.c.

50 {
52  "CLSID\\{deadcafe-beed-bead-dead-cafebeaddead}\\Implemented Categories\\{deadcafe-0000-0000-0000-000000000000}");
54  "CLSID\\{deadcafe-beed-bead-dead-cafebeaddead}\\Implemented Categories");
56  "CLSID\\{deadcafe-beed-bead-dead-cafebeaddead}");
57 }
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
Definition: reg.c:1222
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

Referenced by do_enum().