~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/comcat/register.c

Version: ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  *      ComCatMgr ICatRegister implementation for comcat.dll
  3  *
  4  * Copyright (C) 2002 John K. Hohm
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include "comcat_private.h"
 22 
 23 #include "wine/debug.h"
 24 
 25 WINE_DEFAULT_DEBUG_CHANNEL(ole);
 26 
 27 /**********************************************************************
 28  * File-scope string constants
 29  */
 30 static const WCHAR comcat_keyname[21] = {
 31     'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n', 't', ' ', 'C', 'a',
 32     't', 'e', 'g', 'o', 'r', 'i', 'e', 's', 0 };
 33 static const WCHAR impl_keyname[23] = {
 34     'I', 'm', 'p', 'l', 'e', 'm', 'e', 'n',
 35     't', 'e', 'd', ' ', 'C', 'a', 't', 'e',
 36     'g', 'o', 'r', 'i', 'e', 's', 0 };
 37 static const WCHAR req_keyname[20] = {
 38     'R', 'e', 'q', 'u', 'i', 'r', 'e', 'd',
 39     ' ', 'C', 'a', 't', 'e', 'g', 'o', 'r',
 40     'i', 'e', 's', 0 };
 41 
 42 static HRESULT COMCAT_RegisterClassCategories(
 43     REFCLSID rclsid, LPCWSTR type,
 44     ULONG cCategories, const CATID *rgcatid);
 45 static HRESULT COMCAT_UnRegisterClassCategories(
 46     REFCLSID rclsid, LPCWSTR type,
 47     ULONG cCategories, const CATID *rgcatid);
 48 
 49 /**********************************************************************
 50  * COMCAT_ICatRegister_QueryInterface
 51  */
 52 static HRESULT WINAPI COMCAT_ICatRegister_QueryInterface(
 53     LPCATREGISTER iface,
 54     REFIID riid,
 55     LPVOID *ppvObj)
 56 {
 57     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
 58     TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
 59 
 60     if (This == NULL || ppvObj == NULL) return E_POINTER;
 61 
 62     return IUnknown_QueryInterface((LPUNKNOWN)&This->unkVtbl, riid, ppvObj);
 63 }
 64 
 65 /**********************************************************************
 66  * COMCAT_ICatRegister_AddRef
 67  */
 68 static ULONG WINAPI COMCAT_ICatRegister_AddRef(LPCATREGISTER iface)
 69 {
 70     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
 71     TRACE("\n");
 72 
 73     if (This == NULL) return E_POINTER;
 74 
 75     return IUnknown_AddRef((LPUNKNOWN)&This->unkVtbl);
 76 }
 77 
 78 /**********************************************************************
 79  * COMCAT_ICatRegister_Release
 80  */
 81 static ULONG WINAPI COMCAT_ICatRegister_Release(LPCATREGISTER iface)
 82 {
 83     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
 84     TRACE("\n");
 85 
 86     if (This == NULL) return E_POINTER;
 87 
 88     return IUnknown_Release((LPUNKNOWN)&This->unkVtbl);
 89 }
 90 
 91 /**********************************************************************
 92  * COMCAT_ICatRegister_RegisterCategories
 93  */
 94 static HRESULT WINAPI COMCAT_ICatRegister_RegisterCategories(
 95     LPCATREGISTER iface,
 96     ULONG cCategories,
 97     CATEGORYINFO *rgci)
 98 {
 99 /*     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
100     HKEY comcat_key;
101     HRESULT res;
102 
103     TRACE("\n");
104 
105     if (iface == NULL || (cCategories && rgci == NULL))
106         return E_POINTER;
107 
108     /* Create (or open) the component categories key. */
109     res = RegCreateKeyExW(HKEY_CLASSES_ROOT, comcat_keyname, 0, NULL, 0,
110                           KEY_READ | KEY_WRITE, NULL, &comcat_key, NULL);
111     if (res != ERROR_SUCCESS) return E_FAIL;
112 
113     for (; cCategories; --cCategories, ++rgci) {
114         static const WCHAR fmt[] = { '%', 'l', 'X', 0 };
115         WCHAR keyname[39];
116         WCHAR valname[9];
117         HKEY cat_key;
118 
119         /* Create (or open) the key for this category. */
120         if (!StringFromGUID2(&rgci->catid, keyname, 39)) continue;
121         res = RegCreateKeyExW(comcat_key, keyname, 0, NULL, 0,
122                               KEY_READ | KEY_WRITE, NULL, &cat_key, NULL);
123         if (res != ERROR_SUCCESS) continue;
124 
125         /* Set the value for this locale's description. */
126         wsprintfW(valname, fmt, rgci->lcid);
127         RegSetValueExW(cat_key, valname, 0, REG_SZ,
128                        (CONST BYTE*)(rgci->szDescription),
129                        (lstrlenW(rgci->szDescription) + 1) * sizeof(WCHAR));
130 
131         RegCloseKey(cat_key);
132     }
133 
134     RegCloseKey(comcat_key);
135     return S_OK;
136 }
137 
138 /**********************************************************************
139  * COMCAT_ICatRegister_UnRegisterCategories
140  */
141 static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterCategories(
142     LPCATREGISTER iface,
143     ULONG cCategories,
144     CATID *rgcatid)
145 {
146 /*     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
147     HKEY comcat_key;
148     HRESULT res;
149 
150     TRACE("\n");
151 
152     if (iface == NULL || (cCategories && rgcatid == NULL))
153         return E_POINTER;
154 
155     /* Open the component categories key. */
156     res = RegOpenKeyExW(HKEY_CLASSES_ROOT, comcat_keyname, 0,
157                         KEY_READ | KEY_WRITE, &comcat_key);
158     if (res != ERROR_SUCCESS) return E_FAIL;
159 
160     for (; cCategories; --cCategories, ++rgcatid) {
161         WCHAR keyname[39];
162 
163         /* Delete the key for this category. */
164         if (!StringFromGUID2(rgcatid, keyname, 39)) continue;
165         RegDeleteKeyW(comcat_key, keyname);
166     }
167 
168     RegCloseKey(comcat_key);
169     return S_OK;
170 }
171 
172 /**********************************************************************
173  * COMCAT_ICatRegister_RegisterClassImplCategories
174  */
175 static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassImplCategories(
176     LPCATREGISTER iface,
177     REFCLSID rclsid,
178     ULONG cCategories,
179     CATID *rgcatid)
180 {
181 /*     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
182     TRACE("\n");
183 
184     return COMCAT_RegisterClassCategories(
185         rclsid, impl_keyname, cCategories, rgcatid);
186 }
187 
188 /**********************************************************************
189  * COMCAT_ICatRegister_UnRegisterClassImplCategories
190  */
191 static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassImplCategories(
192     LPCATREGISTER iface,
193     REFCLSID rclsid,
194     ULONG cCategories,
195     CATID *rgcatid)
196 {
197 /*     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
198     TRACE("\n");
199 
200     return COMCAT_UnRegisterClassCategories(
201         rclsid, impl_keyname, cCategories, rgcatid);
202 }
203 
204 /**********************************************************************
205  * COMCAT_ICatRegister_RegisterClassReqCategories
206  */
207 static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassReqCategories(
208     LPCATREGISTER iface,
209     REFCLSID rclsid,
210     ULONG cCategories,
211     CATID *rgcatid)
212 {
213 /*     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
214     TRACE("\n");
215 
216     return COMCAT_RegisterClassCategories(
217         rclsid, req_keyname, cCategories, rgcatid);
218 }
219 
220 /**********************************************************************
221  * COMCAT_ICatRegister_UnRegisterClassReqCategories
222  */
223 static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassReqCategories(
224     LPCATREGISTER iface,
225     REFCLSID rclsid,
226     ULONG cCategories,
227     CATID *rgcatid)
228 {
229 /*     ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
230     TRACE("\n");
231 
232     return COMCAT_UnRegisterClassCategories(
233         rclsid, req_keyname, cCategories, rgcatid);
234 }
235 
236 /**********************************************************************
237  * COMCAT_ICatRegister_Vtbl
238  */
239 const ICatRegisterVtbl COMCAT_ICatRegister_Vtbl =
240 {
241     COMCAT_ICatRegister_QueryInterface,
242     COMCAT_ICatRegister_AddRef,
243     COMCAT_ICatRegister_Release,
244     COMCAT_ICatRegister_RegisterCategories,
245     COMCAT_ICatRegister_UnRegisterCategories,
246     COMCAT_ICatRegister_RegisterClassImplCategories,
247     COMCAT_ICatRegister_UnRegisterClassImplCategories,
248     COMCAT_ICatRegister_RegisterClassReqCategories,
249     COMCAT_ICatRegister_UnRegisterClassReqCategories
250 };
251 
252 /**********************************************************************
253  * COMCAT_RegisterClassCategories
254  */
255 static HRESULT COMCAT_RegisterClassCategories(
256     REFCLSID rclsid,
257     LPCWSTR type,
258     ULONG cCategories,
259     const CATID *rgcatid)
260 {
261     WCHAR keyname[39];
262     HRESULT res;
263     HKEY clsid_key, class_key, type_key;
264 
265     if (cCategories && rgcatid == NULL) return E_POINTER;
266 
267     /* Format the class key name. */
268     res = StringFromGUID2(rclsid, keyname, 39);
269     if (FAILED(res)) return res;
270 
271     /* Create (or open) the CLSID key. */
272     res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
273                           KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
274     if (res != ERROR_SUCCESS) return E_FAIL;
275 
276     /* Create (or open) the class key. */
277     res = RegCreateKeyExW(clsid_key, keyname, 0, NULL, 0,
278                           KEY_READ | KEY_WRITE, NULL, &class_key, NULL);
279     if (res == ERROR_SUCCESS) {
280         /* Create (or open) the category type key. */
281         res = RegCreateKeyExW(class_key, type, 0, NULL, 0,
282                               KEY_READ | KEY_WRITE, NULL, &type_key, NULL);
283         if (res == ERROR_SUCCESS) {
284             for (; cCategories; --cCategories, ++rgcatid) {
285                 HKEY key;
286 
287                 /* Format the category key name. */
288                 res = StringFromGUID2(rgcatid, keyname, 39);
289                 if (FAILED(res)) continue;
290 
291                 /* Do the register. */
292                 res = RegCreateKeyExW(type_key, keyname, 0, NULL, 0,
293                                       KEY_READ | KEY_WRITE, NULL, &key, NULL);
294                 if (res == ERROR_SUCCESS) RegCloseKey(key);
295             }
296             res = S_OK;
297         } else res = E_FAIL;
298         RegCloseKey(class_key);
299     } else res = E_FAIL;
300     RegCloseKey(clsid_key);
301 
302     return res;
303 }
304 
305 /**********************************************************************
306  * COMCAT_UnRegisterClassCategories
307  */
308 static HRESULT COMCAT_UnRegisterClassCategories(
309     REFCLSID rclsid,
310     LPCWSTR type,
311     ULONG cCategories,
312     const CATID *rgcatid)
313 {
314     WCHAR keyname[68] = { 'C', 'L', 'S', 'I', 'D', '\\' };
315     HRESULT res;
316     HKEY type_key;
317 
318     if (cCategories && rgcatid == NULL) return E_POINTER;
319 
320     /* Format the class category type key name. */
321     res = StringFromGUID2(rclsid, keyname + 6, 39);
322     if (FAILED(res)) return res;
323     keyname[44] = '\\';
324     lstrcpyW(keyname + 45, type);
325 
326     /* Open the class category type key. */
327     res = RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0,
328                         KEY_READ | KEY_WRITE, &type_key);
329     if (res != ERROR_SUCCESS) return E_FAIL;
330 
331     for (; cCategories; --cCategories, ++rgcatid) {
332         /* Format the category key name. */
333         res = StringFromGUID2(rgcatid, keyname, 39);
334         if (FAILED(res)) continue;
335 
336         /* Do the unregister. */
337         RegDeleteKeyW(type_key, keyname);
338     }
339     RegCloseKey(type_key);
340 
341     return S_OK;
342 }
343 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.