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