ReactOS 0.4.15-dev-7953-g1f49173
CComCatCachedCategory Class Reference
Collaboration diagram for CComCatCachedCategory:

Public Member Functions

 CComCatCachedCategory ()
 
virtual ~CComCatCachedCategory ()
 
HRESULT WriteCacheToDSA (HDSA pDest)
 
HRESULT STDMETHODCALLTYPE Initialize (CATID &catID, BOOL reloadCache)
 

Private Member Functions

BOOL LoadFromRegistry ()
 
HRESULT LoadFromComCatMgr ()
 
HRESULT CacheDSA ()
 

Private Attributes

CATID fCategory
 
HDSA fLocalDsa
 

Detailed Description

Definition at line 44 of file CSHEnumClassesOfCategories.cpp.

Constructor & Destructor Documentation

◆ CComCatCachedCategory()

CComCatCachedCategory::CComCatCachedCategory ( )

Definition at line 59 of file CSHEnumClassesOfCategories.cpp.

60{
61 fLocalDsa = DSA_Create(sizeof(GUID), 5);
62}
HDSA WINAPI DSA_Create(INT nSize, INT nGrow)
Definition: dsa.c:71

◆ ~CComCatCachedCategory()

CComCatCachedCategory::~CComCatCachedCategory ( )
virtual

Definition at line 82 of file CSHEnumClassesOfCategories.cpp.

83{
85}
BOOL WINAPI DSA_Destroy(HDSA hdsa)
Definition: dsa.c:103

Member Function Documentation

◆ CacheDSA()

HRESULT CComCatCachedCategory::CacheDSA ( )
private

Definition at line 121 of file CSHEnumClassesOfCategories.cpp.

122{
123 WCHAR bufKey[MAX_PATH];
125 UINT elemCount;
126 UINT i;
128 CComHeapPtr<CATCACHEHDR> buffer;
129 GUID *guidArray;
130 GUID *tmp;
131
132 elemCount = DSA_GetItemCount(fLocalDsa);
133 bufferSize = sizeof(CATCACHEHDR) + elemCount * sizeof(GUID);
135 return E_FAIL;
136
138 if (!buffer)
139 return E_OUTOFMEMORY;
140
141 // Correctly fill cache header
142 buffer->dwSize = sizeof(CATCACHEHDR);
143 buffer->version = 1;
144 GetSystemTime(&buffer->writeTime);
145 buffer->classCount = (DWORD)elemCount;
146
147 guidArray = (GUID*)(buffer + 1);
148 wsprintf(bufKey, L"%s\\%s\\%s", REGPATH , guidStr, L"Enum");
149
150 // Write DSA contents inside the memory buffer allocated
151 for(i = 0; i < elemCount; i++)
152 {
153 tmp = (GUID*)DSA_GetItemPtr(fLocalDsa, i);
154 if (tmp)
155 {
156 guidArray[i] = *tmp;
157 }
158 }
159
160 // Save items to registry
162
163 guidArray = NULL;
164 return S_OK;
165}
#define REGPATH
#define IMPLEMENTING
struct categoryCacheHeader CATCACHEHDR
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2434
LPVOID WINAPI DSA_GetItemPtr(HDSA hdsa, INT nIndex)
Definition: dsa.c:162
size_t bufferSize
GLuint buffer
Definition: glext.h:5915
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#define S_OK
Definition: intsafe.h:52
static WCHAR guidStr[]
Definition: asn.c:531
unsigned int UINT
Definition: ndis.h:50
#define REG_BINARY
Definition: nt_native.h:1496
#define DWORD
Definition: nt_native.h:44
#define L(x)
Definition: ntvdm.h:50
#define DSA_GetItemCount(hdsa)
Definition: commctrl.h:4826
#define SHSetValue
Definition: shlwapi.h:92
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define wsprintf
Definition: winuser.h:5865
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by Initialize().

◆ Initialize()

HRESULT STDMETHODCALLTYPE CComCatCachedCategory::Initialize ( CATID catID,
BOOL  reloadCache 
)

Definition at line 64 of file CSHEnumClassesOfCategories.cpp.

65{
66 HRESULT hr;
67
68 fCategory = catID;
69 if (reloadCache || !LoadFromRegistry())
70 {
73 return hr;
74
75 hr = CacheDSA();
77 return hr;
78 }
79 return S_OK;
80}
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT hr
Definition: shlfolder.c:183

Referenced by CSHEnumClassesOfCategories::Initialize().

◆ LoadFromComCatMgr()

HRESULT CComCatCachedCategory::LoadFromComCatMgr ( )
private

Definition at line 167 of file CSHEnumClassesOfCategories.cpp.

168{
169 HRESULT hr;
170 CComPtr<ICatInformation> pCatInformation;
171 CComPtr<IEnumGUID> pEnumGUID;
172 ULONG pFetched;
173 CLSID tmp;
174
175 // Get component categories manager instance
176 hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER,
177 IID_PPV_ARG(ICatInformation, &pCatInformation));
179 return hr;
180
181 // Get the proper enumerator
182 hr = pCatInformation->EnumClassesOfCategories(1, &fCategory, NULL, NULL, &pEnumGUID);
184 return hr;
185
186 // Enumerate elements
187 do
188 {
189 pFetched = 0;
190 pEnumGUID->Next(1, &tmp, &pFetched);
191 if (pFetched)
192 {
194 return E_OUTOFMEMORY;
195 }
196 }
197 while (pFetched > 0);
198 return S_OK;
199}
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
INT WINAPI DSA_InsertItem(HDSA hdsa, INT nIndex, LPVOID pSrc)
Definition: dsa.c:251
#define DSA_APPEND
Definition: commctrl.h:4787
uint32_t ULONG
Definition: typedefs.h:59
#define IID_PPV_ARG(Itype, ppType)

Referenced by Initialize().

◆ LoadFromRegistry()

BOOL CComCatCachedCategory::LoadFromRegistry ( )
private

Definition at line 87 of file CSHEnumClassesOfCategories.cpp.

88{
89 WCHAR bufKey[MAX_PATH];
92 CComHeapPtr<CATCACHEHDR> buffer;
93 GUID *guidArray;
94
95 if (!fLocalDsa)
96 return FALSE;
97
98 dataSize = 0;
100 return FALSE;
101
102 wsprintf(bufKey, L"%s\\%s\\%s", REGPATH , guidStr, L"Enum");
103
104 // Try to read key and get proper value size
106 return FALSE;
107
109
111 guidArray = (GUID*)(buffer + 1);
112 for (i = 0; i < buffer->classCount; i++)
113 {
114 // Add class to cache
115 DSA_InsertItem(fLocalDsa, DSA_APPEND, guidArray + i);
116 }
117
118 return TRUE;
119}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei dataSize
Definition: glext.h:11123
#define SHGetValue
Definition: shlwapi.h:70

Referenced by Initialize().

◆ WriteCacheToDSA()

HRESULT CComCatCachedCategory::WriteCacheToDSA ( HDSA  pDest)

Definition at line 201 of file CSHEnumClassesOfCategories.cpp.

202{
203 INT i;
204 for(i = 0; i < DSA_GetItemCount(fLocalDsa); i++)
205 {
207 return E_OUTOFMEMORY;
208 }
209 return S_OK;
210}
#define DSA_ERR
Definition: commctrl.h:4788
int32_t INT
Definition: typedefs.h:58

Referenced by CSHEnumClassesOfCategories::Initialize().

Member Data Documentation

◆ fCategory

CATID CComCatCachedCategory::fCategory
private

◆ fLocalDsa

HDSA CComCatCachedCategory::fLocalDsa
private

The documentation for this class was generated from the following file: