shell32: Export IsUserAnAdmin by name as well.
[wine] / dlls / shell32 / regsvr.c
1 /*
2  *      self-registerable dll functions for shell32.dll
3  *
4  * Copyright (C) 2003 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 <stdarg.h>
22 #include <string.h>
23 #include <stdio.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "winreg.h"
29 #include "winerror.h"
30
31 #include "ole2.h"
32 #include "shldisp.h"
33 #include "shlguid.h"
34 #include "shell32_main.h"
35 #include "shresdef.h"
36 #include "initguid.h"
37 #include "shfldr.h"
38
39 #include "wine/debug.h"
40 #include "wine/unicode.h"
41
42 WINE_DEFAULT_DEBUG_CHANNEL(ole);
43
44 /*
45  * Near the bottom of this file are the exported DllRegisterServer and
46  * DllUnregisterServer, which make all this worthwhile.
47  */
48
49 /***********************************************************************
50  *              interface for self-registering
51  */
52 struct regsvr_interface
53 {
54     IID const *iid;             /* NULL for end of list */
55     LPCSTR name;                /* can be NULL to omit */
56     IID const *base_iid;        /* can be NULL to omit */
57     int num_methods;            /* can be <0 to omit */
58     CLSID const *ps_clsid;      /* can be NULL to omit */
59     CLSID const *ps_clsid32;    /* can be NULL to omit */
60 };
61
62 static HRESULT register_interfaces(struct regsvr_interface const *list);
63 static HRESULT unregister_interfaces(struct regsvr_interface const *list);
64
65 struct regsvr_coclass
66 {
67     CLSID const *clsid;         /* NULL for end of list */
68     LPCSTR name;                /* can be NULL to omit */
69     UINT idName;                /* can be 0 to omit */
70     LPCSTR ips;                 /* can be NULL to omit */
71     LPCSTR ips32;               /* can be NULL to omit */
72     LPCSTR ips32_tmodel;        /* can be NULL to omit */
73     DWORD flags;
74     DWORD dwAttributes;
75     DWORD dwCallForAttributes;
76     LPCSTR clsid_str;           /* can be NULL to omit */
77     LPCSTR progid;              /* can be NULL to omit */
78     UINT idDefaultIcon;         /* can be 0 to omit */
79 };
80
81 /* flags for regsvr_coclass.flags */
82 #define SHELLEX_MAYCHANGEDEFAULTMENU  0x00000001
83 #define SHELLFOLDER_WANTSFORPARSING   0x00000002
84 #define SHELLFOLDER_WANTSFORDISPLAY   0x00000004
85 #define SHELLFOLDER_ATTRIBUTES        0x00000008
86 #define SHELLFOLDER_CALLFORATTRIBUTES 0x00000010
87 #define SHELLFOLDER_HIDEASDELETE      0x00000020
88
89 static HRESULT register_coclasses(struct regsvr_coclass const *list);
90 static HRESULT unregister_coclasses(struct regsvr_coclass const *list);
91
92 struct regsvr_namespace
93 {
94     CLSID const *clsid; /* CLSID of the namespace extension. NULL for end of list */
95     LPCWSTR parent;     /* Mount point (MyComputer, Desktop, ..). */
96     LPCWSTR value;      /* Display name of the extension. */
97 };
98
99 static HRESULT register_namespace_extensions(struct regsvr_namespace const *list);
100 static HRESULT unregister_namespace_extensions(struct regsvr_namespace const *list);
101
102 /***********************************************************************
103  *              static string constants
104  */
105 static WCHAR const interface_keyname[10] = {
106     'I', 'n', 't', 'e', 'r', 'f', 'a', 'c', 'e', 0 };
107 static WCHAR const base_ifa_keyname[14] = {
108     'B', 'a', 's', 'e', 'I', 'n', 't', 'e', 'r', 'f', 'a', 'c',
109     'e', 0 };
110 static WCHAR const num_methods_keyname[11] = {
111     'N', 'u', 'm', 'M', 'e', 't', 'h', 'o', 'd', 's', 0 };
112 static WCHAR const ps_clsid_keyname[15] = {
113     'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
114     'i', 'd', 0 };
115 static WCHAR const ps_clsid32_keyname[17] = {
116     'P', 'r', 'o', 'x', 'y', 'S', 't', 'u', 'b', 'C', 'l', 's',
117     'i', 'd', '3', '2', 0 };
118 static WCHAR const clsid_keyname[6] = {
119     'C', 'L', 'S', 'I', 'D', 0 };
120 static WCHAR const ips_keyname[13] = {
121     'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
122     0 };
123 static WCHAR const ips32_keyname[15] = {
124     'I', 'n', 'P', 'r', 'o', 'c', 'S', 'e', 'r', 'v', 'e', 'r',
125     '3', '2', 0 };
126 static WCHAR const progid_keyname[7] = {
127     'P', 'r', 'o', 'g', 'I', 'D', 0 };
128 static WCHAR const shellex_keyname[8] = {
129     's', 'h', 'e', 'l', 'l', 'e', 'x', 0 };
130 static WCHAR const shellfolder_keyname[12] = {
131     'S', 'h', 'e', 'l', 'l', 'F', 'o', 'l', 'd', 'e', 'r', 0 };
132 static WCHAR const mcdm_keyname[21] = {
133     'M', 'a', 'y', 'C', 'h', 'a', 'n', 'g', 'e', 'D', 'e', 'f',
134     'a', 'u', 'l', 't', 'M', 'e', 'n', 'u', 0 };
135 static WCHAR const defaulticon_keyname[] = {
136     'D','e','f','a','u','l','t','I','c','o','n',0};
137 static char const tmodel_valuename[] = "ThreadingModel";
138 static char const wfparsing_valuename[] = "WantsFORPARSING";
139 static char const wfdisplay_valuename[] = "WantsFORDISPLAY";
140 static char const attributes_valuename[] = "Attributes";
141 static char const cfattributes_valuename[] = "CallForAttributes";
142 static char const localized_valuename[] = "LocalizedString";
143 static char const hideasdelete_valuename[] = "HideAsDeletePerUser";
144
145 /***********************************************************************
146  *              static helper functions
147  */
148 static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid);
149 static LONG register_key_defvalueW(HKEY base, WCHAR const *name,
150                                    WCHAR const *value);
151 static LONG register_key_defvalueA(HKEY base, WCHAR const *name,
152                                    char const *value);
153
154 /***********************************************************************
155  *              register_interfaces
156  */
157 static HRESULT register_interfaces(struct regsvr_interface const *list)
158 {
159     LONG res = ERROR_SUCCESS;
160     HKEY interface_key;
161
162     res = RegCreateKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0, NULL, 0,
163                           KEY_READ | KEY_WRITE, NULL, &interface_key, NULL);
164     if (res != ERROR_SUCCESS) goto error_return;
165
166     for (; res == ERROR_SUCCESS && list->iid; ++list) {
167         WCHAR buf[39];
168         HKEY iid_key;
169
170         StringFromGUID2(list->iid, buf, 39);
171         res = RegCreateKeyExW(interface_key, buf, 0, NULL, 0,
172                               KEY_READ | KEY_WRITE, NULL, &iid_key, NULL);
173         if (res != ERROR_SUCCESS) goto error_close_interface_key;
174
175         if (list->name) {
176             res = RegSetValueExA(iid_key, NULL, 0, REG_SZ,
177                                  (CONST BYTE*)(list->name),
178                                  strlen(list->name) + 1);
179             if (res != ERROR_SUCCESS) goto error_close_iid_key;
180         }
181
182         if (list->base_iid) {
183             res = register_key_guid(iid_key, base_ifa_keyname, list->base_iid);
184             if (res != ERROR_SUCCESS) goto error_close_iid_key;
185         }
186
187         if (0 <= list->num_methods) {
188             static WCHAR const fmt[3] = { '%', 'd', 0 };
189             HKEY key;
190
191             res = RegCreateKeyExW(iid_key, num_methods_keyname, 0, NULL, 0,
192                                   KEY_READ | KEY_WRITE, NULL, &key, NULL);
193             if (res != ERROR_SUCCESS) goto error_close_iid_key;
194
195             sprintfW(buf, fmt, list->num_methods);
196             res = RegSetValueExW(key, NULL, 0, REG_SZ,
197                                  (CONST BYTE*)buf,
198                                  (lstrlenW(buf) + 1) * sizeof(WCHAR));
199             RegCloseKey(key);
200
201             if (res != ERROR_SUCCESS) goto error_close_iid_key;
202         }
203
204         if (list->ps_clsid) {
205             res = register_key_guid(iid_key, ps_clsid_keyname, list->ps_clsid);
206             if (res != ERROR_SUCCESS) goto error_close_iid_key;
207         }
208
209         if (list->ps_clsid32) {
210             res = register_key_guid(iid_key, ps_clsid32_keyname, list->ps_clsid32);
211             if (res != ERROR_SUCCESS) goto error_close_iid_key;
212         }
213
214     error_close_iid_key:
215         RegCloseKey(iid_key);
216     }
217
218 error_close_interface_key:
219     RegCloseKey(interface_key);
220 error_return:
221     return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
222 }
223
224 /***********************************************************************
225  *              unregister_interfaces
226  */
227 static HRESULT unregister_interfaces(struct regsvr_interface const *list)
228 {
229     LONG res = ERROR_SUCCESS;
230     HKEY interface_key;
231
232     res = RegOpenKeyExW(HKEY_CLASSES_ROOT, interface_keyname, 0,
233                         KEY_READ | KEY_WRITE, &interface_key);
234     if (res == ERROR_FILE_NOT_FOUND) return S_OK;
235     if (res != ERROR_SUCCESS) goto error_return;
236
237     for (; res == ERROR_SUCCESS && list->iid; ++list) {
238         WCHAR buf[39];
239
240         StringFromGUID2(list->iid, buf, 39);
241         res = RegDeleteTreeW(interface_key, buf);
242         if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
243     }
244
245     RegCloseKey(interface_key);
246 error_return:
247     return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
248 }
249
250 /***********************************************************************
251  *              register_coclasses
252  */
253 static HRESULT register_coclasses(struct regsvr_coclass const *list)
254 {
255     LONG res = ERROR_SUCCESS;
256     HKEY coclass_key;
257
258     res = RegCreateKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0, NULL, 0,
259                           KEY_READ | KEY_WRITE, NULL, &coclass_key, NULL);
260     if (res != ERROR_SUCCESS) goto error_return;
261
262     for (; res == ERROR_SUCCESS && list->clsid; ++list) {
263         WCHAR buf[39];
264         HKEY clsid_key;
265
266         StringFromGUID2(list->clsid, buf, 39);
267         res = RegCreateKeyExW(coclass_key, buf, 0, NULL, 0,
268                               KEY_READ | KEY_WRITE, NULL, &clsid_key, NULL);
269         if (res != ERROR_SUCCESS) goto error_close_coclass_key;
270
271         if (list->name) {
272             res = RegSetValueExA(clsid_key, NULL, 0, REG_SZ,
273                                  (CONST BYTE*)(list->name),
274                                  strlen(list->name) + 1);
275             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
276         }
277
278         if (list->idName) {
279             char buffer[64];
280             sprintf(buffer, "@shell32.dll,-%u", list->idName);
281             res = RegSetValueExA(clsid_key, localized_valuename, 0, REG_SZ,
282                                  (CONST BYTE*)(buffer), strlen(buffer)+1);
283             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
284         }
285         
286         if (list->idDefaultIcon) {
287             HKEY icon_key;
288             char buffer[64];
289
290             res = RegCreateKeyExW(clsid_key, defaulticon_keyname, 0, NULL, 0,
291                         KEY_READ | KEY_WRITE, NULL, &icon_key, NULL);
292             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
293
294             sprintf(buffer, "shell32.dll,-%u", list->idDefaultIcon);
295             res = RegSetValueExA(icon_key, NULL, 0, REG_SZ,
296                                  (CONST BYTE*)(buffer), strlen(buffer)+1);
297             RegCloseKey(icon_key);
298             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
299         }
300
301         if (list->ips) {
302             res = register_key_defvalueA(clsid_key, ips_keyname, list->ips);
303             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
304         }
305
306         if (list->ips32) {
307             HKEY ips32_key;
308
309             res = RegCreateKeyExW(clsid_key, ips32_keyname, 0, NULL, 0,
310                                   KEY_READ | KEY_WRITE, NULL,
311                                   &ips32_key, NULL);
312             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
313
314             res = RegSetValueExA(ips32_key, NULL, 0, REG_SZ,
315                                  (CONST BYTE*)list->ips32,
316                                  lstrlenA(list->ips32) + 1);
317             if (res == ERROR_SUCCESS && list->ips32_tmodel)
318                 res = RegSetValueExA(ips32_key, tmodel_valuename, 0, REG_SZ,
319                                      (CONST BYTE*)list->ips32_tmodel,
320                                      strlen(list->ips32_tmodel) + 1);
321             RegCloseKey(ips32_key);
322             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
323         }
324
325         if (list->flags & SHELLEX_MAYCHANGEDEFAULTMENU) {
326             HKEY shellex_key, mcdm_key;
327
328             res = RegCreateKeyExW(clsid_key, shellex_keyname, 0, NULL, 0,
329                                   KEY_READ | KEY_WRITE, NULL,
330                                   &shellex_key, NULL);
331             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
332             res = RegCreateKeyExW(shellex_key, mcdm_keyname, 0, NULL, 0,
333                                   KEY_READ | KEY_WRITE, NULL,
334                                   &mcdm_key, NULL);
335             RegCloseKey(shellex_key);
336             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
337             RegCloseKey(mcdm_key);
338         }
339
340         if (list->flags & 
341                 (SHELLFOLDER_WANTSFORPARSING|SHELLFOLDER_WANTSFORDISPLAY|SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES|SHELLFOLDER_HIDEASDELETE))
342         {
343             HKEY shellfolder_key;
344
345             res = RegCreateKeyExW(clsid_key, shellfolder_keyname, 0, NULL, 0,
346                                   KEY_READ | KEY_WRITE, NULL,
347                                   &shellfolder_key, NULL);
348             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
349             if (list->flags & SHELLFOLDER_WANTSFORPARSING)
350                 res = RegSetValueExA(shellfolder_key, wfparsing_valuename, 0, REG_SZ, (const BYTE *)"", 1);
351             if (list->flags & SHELLFOLDER_WANTSFORDISPLAY)
352                 res = RegSetValueExA(shellfolder_key, wfdisplay_valuename, 0, REG_SZ, (const BYTE *)"", 1);
353             if (list->flags & SHELLFOLDER_HIDEASDELETE)
354                 res = RegSetValueExA(shellfolder_key, hideasdelete_valuename, 0, REG_SZ, (const BYTE *)"", 1);
355             if (list->flags & SHELLFOLDER_ATTRIBUTES) 
356                 res = RegSetValueExA(shellfolder_key, attributes_valuename, 0, REG_DWORD, 
357                                      (const BYTE *)&list->dwAttributes, sizeof(DWORD));
358             if (list->flags & SHELLFOLDER_CALLFORATTRIBUTES) 
359                 res = RegSetValueExA(shellfolder_key, cfattributes_valuename, 0, REG_DWORD,
360                                      (const BYTE *)&list->dwCallForAttributes, sizeof(DWORD));
361             RegCloseKey(shellfolder_key);
362             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
363         }
364
365         if (list->clsid_str) {
366             res = register_key_defvalueA(clsid_key, clsid_keyname,
367                                          list->clsid_str);
368             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
369         }
370
371         if (list->progid) {
372             HKEY progid_key;
373
374             res = register_key_defvalueA(clsid_key, progid_keyname,
375                                          list->progid);
376             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
377
378             res = RegCreateKeyExA(HKEY_CLASSES_ROOT, list->progid, 0,
379                                   NULL, 0, KEY_READ | KEY_WRITE, NULL,
380                                   &progid_key, NULL);
381             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
382
383             res = register_key_defvalueW(progid_key, clsid_keyname, buf);
384             RegCloseKey(progid_key);
385             if (res != ERROR_SUCCESS) goto error_close_clsid_key;
386         }
387
388     error_close_clsid_key:
389         RegCloseKey(clsid_key);
390     }
391
392 error_close_coclass_key:
393     RegCloseKey(coclass_key);
394 error_return:
395     return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
396 }
397
398 /***********************************************************************
399  *              unregister_coclasses
400  */
401 static HRESULT unregister_coclasses(struct regsvr_coclass const *list)
402 {
403     LONG res = ERROR_SUCCESS;
404     HKEY coclass_key;
405
406     res = RegOpenKeyExW(HKEY_CLASSES_ROOT, clsid_keyname, 0,
407                         KEY_READ | KEY_WRITE, &coclass_key);
408     if (res == ERROR_FILE_NOT_FOUND) return S_OK;
409     if (res != ERROR_SUCCESS) goto error_return;
410
411     for (; res == ERROR_SUCCESS && list->clsid; ++list) {
412         WCHAR buf[39];
413
414         StringFromGUID2(list->clsid, buf, 39);
415         res = RegDeleteTreeW(coclass_key, buf);
416         if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
417         if (res != ERROR_SUCCESS) goto error_close_coclass_key;
418
419         if (list->progid) {
420             res = RegDeleteTreeA(HKEY_CLASSES_ROOT, list->progid);
421             if (res == ERROR_FILE_NOT_FOUND) res = ERROR_SUCCESS;
422             if (res != ERROR_SUCCESS) goto error_close_coclass_key;
423         }
424     }
425
426 error_close_coclass_key:
427     RegCloseKey(coclass_key);
428 error_return:
429     return res != ERROR_SUCCESS ? HRESULT_FROM_WIN32(res) : S_OK;
430 }
431
432 /**********************************************************************
433  * register_namespace_extensions
434  */
435 static WCHAR *get_namespace_key(struct regsvr_namespace const *list) {
436     static const WCHAR wszExplorerKey[] = {
437         'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
438         'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
439         'E','x','p','l','o','r','e','r','\\',0 };
440     static const WCHAR wszNamespace[] = { '\\','N','a','m','e','s','p','a','c','e','\\',0 };
441     WCHAR *pwszKey, *pwszCLSID;
442
443     pwszKey = HeapAlloc(GetProcessHeap(), 0, sizeof(wszExplorerKey)+sizeof(wszNamespace)+
444                                              sizeof(WCHAR)*(lstrlenW(list->parent)+CHARS_IN_GUID));
445     if (!pwszKey)
446         return NULL;
447
448     lstrcpyW(pwszKey, wszExplorerKey);
449     lstrcatW(pwszKey, list->parent);
450     lstrcatW(pwszKey, wszNamespace);
451     if (FAILED(StringFromCLSID(list->clsid, &pwszCLSID))) {
452         HeapFree(GetProcessHeap(), 0, pwszKey);
453         return NULL;
454     }
455     lstrcatW(pwszKey, pwszCLSID);
456     CoTaskMemFree(pwszCLSID);
457
458     return pwszKey;
459 }
460
461 static HRESULT register_namespace_extensions(struct regsvr_namespace const *list) {
462     WCHAR *pwszKey;
463     HKEY hKey;
464     
465     for (; list->clsid; list++) {
466         pwszKey = get_namespace_key(list);
467             
468         /* Create the key and set the value. */
469         if (pwszKey && ERROR_SUCCESS == 
470             RegCreateKeyExW(HKEY_LOCAL_MACHINE, pwszKey, 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL)) 
471         {
472             RegSetValueExW(hKey, NULL, 0, REG_SZ, (const BYTE *)list->value, sizeof(WCHAR)*(lstrlenW(list->value)+1));
473             RegCloseKey(hKey);
474         }
475
476         HeapFree(GetProcessHeap(), 0, pwszKey);
477     }
478     return S_OK;
479 }
480
481 static HRESULT unregister_namespace_extensions(struct regsvr_namespace const *list) {
482     WCHAR *pwszKey;
483     
484     for (; list->clsid; list++) {
485         pwszKey = get_namespace_key(list);
486         RegDeleteKeyW(HKEY_LOCAL_MACHINE, pwszKey);
487         HeapFree(GetProcessHeap(), 0, pwszKey);
488     }
489     return S_OK;
490 }
491
492 /***********************************************************************
493  *              regsvr_key_guid
494  */
495 static LONG register_key_guid(HKEY base, WCHAR const *name, GUID const *guid)
496 {
497     WCHAR buf[39];
498
499     StringFromGUID2(guid, buf, 39);
500     return register_key_defvalueW(base, name, buf);
501 }
502
503 /***********************************************************************
504  *              regsvr_key_defvalueW
505  */
506 static LONG register_key_defvalueW(
507     HKEY base,
508     WCHAR const *name,
509     WCHAR const *value)
510 {
511     LONG res;
512     HKEY key;
513
514     res = RegCreateKeyExW(base, name, 0, NULL, 0,
515                           KEY_READ | KEY_WRITE, NULL, &key, NULL);
516     if (res != ERROR_SUCCESS) return res;
517     res = RegSetValueExW(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
518                          (lstrlenW(value) + 1) * sizeof(WCHAR));
519     RegCloseKey(key);
520     return res;
521 }
522
523 /***********************************************************************
524  *              regsvr_key_defvalueA
525  */
526 static LONG register_key_defvalueA(
527     HKEY base,
528     WCHAR const *name,
529     char const *value)
530 {
531     LONG res;
532     HKEY key;
533
534     res = RegCreateKeyExW(base, name, 0, NULL, 0,
535                           KEY_READ | KEY_WRITE, NULL, &key, NULL);
536     if (res != ERROR_SUCCESS) return res;
537     res = RegSetValueExA(key, NULL, 0, REG_SZ, (CONST BYTE*)value,
538                          lstrlenA(value) + 1);
539     RegCloseKey(key);
540     return res;
541 }
542
543 /***********************************************************************
544  *              coclass list
545  */
546 static GUID const CLSID_Desktop = {
547     0x00021400, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} };
548
549 static GUID const CLSID_Shortcut = {
550     0x00021401, 0x0000, 0x0000, {0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46} };
551
552 static struct regsvr_coclass const coclass_list[] = {
553     {   &CLSID_Desktop,
554         "Desktop",
555         IDS_DESKTOP,
556         NULL,
557         "shell32.dll",
558         "Apartment"
559     },
560     {   &CLSID_DragDropHelper,
561         "Shell Drag and Drop Helper",
562         0,
563         NULL,
564         "shell32.dll",
565         "Apartment"
566     },
567     {   &CLSID_MyComputer,
568         "My Computer",
569         IDS_MYCOMPUTER,
570         NULL,
571         "shell32.dll",
572         "Apartment"
573     },
574     {   &CLSID_NetworkPlaces,
575         "My Network Places",
576         0,
577         NULL,
578         "shell32.dll",
579         "Apartment"
580     },
581     {   &CLSID_Shortcut,
582         "Shortcut",
583         0,
584         NULL,
585         "shell32.dll",
586         "Apartment",
587         SHELLEX_MAYCHANGEDEFAULTMENU
588     },
589     {   &CLSID_AutoComplete,
590         "AutoComplete",
591         0,
592         NULL,
593         "shell32.dll",
594         "Apartment",
595     },
596     {   &CLSID_UnixFolder,
597         "/",
598         0,
599         NULL,
600         "shell32.dll",
601         "Apartment",
602         SHELLFOLDER_WANTSFORPARSING
603     },
604     {   &CLSID_UnixDosFolder,
605         "/",
606         0,
607         NULL,
608         "shell32.dll",
609         "Apartment",
610         SHELLFOLDER_WANTSFORPARSING|SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES,
611         SFGAO_FILESYSANCESTOR|SFGAO_FOLDER|SFGAO_HASSUBFOLDER,
612         SFGAO_FILESYSTEM
613     },
614     {   &CLSID_FolderShortcut,
615         "Foldershortcut",
616         0,
617         NULL,
618         "shell32.dll",
619         "Apartment",
620         SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES,
621         SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_LINK,
622         SFGAO_HASSUBFOLDER|SFGAO_FILESYSTEM|SFGAO_FOLDER|SFGAO_FILESYSANCESTOR
623     },
624     {   &CLSID_MyDocuments,
625         "My Documents",
626         IDS_PERSONAL,
627         NULL,
628         "shell32.dll",
629         "Apartment",
630         SHELLFOLDER_WANTSFORPARSING|SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_CALLFORATTRIBUTES,
631         SFGAO_FILESYSANCESTOR|SFGAO_FOLDER|SFGAO_HASSUBFOLDER,
632         SFGAO_FILESYSTEM
633     },
634     {   &CLSID_RecycleBin,
635         "Trash",
636         IDS_RECYCLEBIN_FOLDER_NAME,
637         NULL,
638         "shell32.dll",
639         "Apartment",
640         SHELLFOLDER_ATTRIBUTES,
641         SFGAO_FOLDER|SFGAO_DROPTARGET|SFGAO_HASPROPSHEET,
642         0,
643         NULL,
644         NULL,
645         IDI_SHELL_FULL_RECYCLE_BIN
646     },
647     {   &CLSID_ShellFSFolder,
648         "Shell File System Folder",
649         0,
650         NULL,
651         "shell32.dll",
652         "Apartment"
653     },
654     {   &CLSID_ShellFolderViewOC,
655         "Microsoft Shell Folder View Router",
656         0,
657         NULL,
658         "shell32.dll",
659         "Apartment"
660     },
661     {   &CLSID_QueryAssociations,
662         "Query file associations",
663         0,
664         NULL,
665         "shell32.dll",
666         "Apartment"
667     },
668     {   &CLSID_ControlPanel,
669         "Control Panel",
670         IDS_CONTROLPANEL,
671         NULL,
672         "shell32.dll",
673         "Apartment",
674         SHELLFOLDER_WANTSFORDISPLAY|SHELLFOLDER_ATTRIBUTES|SHELLFOLDER_HIDEASDELETE,
675         SFGAO_FOLDER|SFGAO_HASSUBFOLDER,
676     },
677     { NULL }                    /* list terminator */
678 };
679
680 /***********************************************************************
681  *              interface list
682  */
683
684 static struct regsvr_interface const interface_list[] = {
685     { NULL }                    /* list terminator */
686 };
687
688 /***********************************************************************
689  *              namespace extensions list
690  */
691 static const WCHAR wszDesktop[] = { 'D','e','s','k','t','o','p',0 };
692 static const WCHAR wszSlash[] = { '/', 0 };
693 static const WCHAR wszMyDocuments[] = { 'M','y',' ','D','o','c','u','m','e','n','t','s', 0 };
694 static const WCHAR wszRecycleBin[] = { 'T','r','a','s','h', 0 };
695 static const WCHAR wszMyComputer[] = { 'M','y','C','o','m','p','u','t','e','r', 0 };
696 static const WCHAR wszControlPanel[] = { 'C','o','n','t','r','o','l',' ','P','a','n','e','l', 0 };
697
698 static struct regsvr_namespace const namespace_extensions_list[] = {
699     {   
700         &CLSID_UnixDosFolder,
701         wszDesktop,
702         wszSlash
703     },
704     {   
705         &CLSID_MyDocuments,
706         wszDesktop,
707         wszMyDocuments
708     },
709     {   
710         &CLSID_RecycleBin,
711         wszDesktop,
712         wszRecycleBin
713     },
714     {
715         &CLSID_ControlPanel,
716         wszMyComputer,
717         wszControlPanel
718     },
719     { NULL }
720 };
721
722 /***********************************************************************
723  *              DllRegisterServer (SHELL32.@)
724  */
725 HRESULT WINAPI DllRegisterServer(void)
726 {
727     HRESULT hr;
728
729     TRACE("\n");
730
731     hr = register_coclasses(coclass_list);
732     if (SUCCEEDED(hr))
733         hr = register_interfaces(interface_list);
734     if (SUCCEEDED(hr))
735         hr = SHELL_RegisterShellFolders();
736     if (SUCCEEDED(hr))
737         hr = register_namespace_extensions(namespace_extensions_list);
738     return hr;
739 }
740
741 /***********************************************************************
742  *              DllUnregisterServer (SHELL32.@)
743  */
744 HRESULT WINAPI DllUnregisterServer(void)
745 {
746     HRESULT hr;
747
748     TRACE("\n");
749
750     hr = unregister_coclasses(coclass_list);
751     if (SUCCEEDED(hr))
752         hr = unregister_interfaces(interface_list);
753     if (SUCCEEDED(hr))
754         hr = unregister_namespace_extensions(namespace_extensions_list);
755     return hr;
756 }