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