Fix code assuming that the Reg* functions set the last error code
[reactos.git] / reactos / lib / userenv / setup.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2004 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id$
20 *
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS system libraries
23 * FILE: lib/userenv/setup.c
24 * PURPOSE: Profile setup functions
25 * PROGRAMMER: Eric Kohl
26 */
27
28 #include <precomp.h>
29
30 #define NDEBUG
31 #include <debug.h>
32
33
34 typedef struct _FOLDERDATA
35 {
36 LPWSTR lpValueName;
37 LPWSTR lpPath;
38 UINT uId;
39 BOOL bHidden;
40 BOOL bShellFolder;
41 BOOL bUserShellFolder;
42 } FOLDERDATA, *PFOLDERDATA;
43
44
45 static FOLDERDATA
46 UserShellFolders[] =
47 {
48 {L"AppData", L"Application Data", IDS_APPDATA, TRUE, TRUE, TRUE},
49 {L"Desktop", L"Desktop", IDS_DESKTOP, FALSE, TRUE, TRUE},
50 {L"Favorites", L"Favorites", IDS_FAVORITES, FALSE, TRUE, TRUE},
51 {L"Personal", L"My Documents", IDS_MYDOCUMENTS, FALSE, TRUE, TRUE},
52 {L"My Pictures", L"My Documents\\My Pictures", IDS_MYPICTURES, FALSE, TRUE, TRUE},
53 {L"My Music", L"My Documents\\My Music", IDS_MYMUSIC, FALSE, TRUE, TRUE},
54 {L"My Video", L"My Documents\\My Videos", IDS_MYVIDEOS, FALSE, TRUE, TRUE},
55 {L"NetHood", L"NetHood", IDS_NETHOOD, TRUE, TRUE, TRUE},
56 {L"PrintHood", L"PrintHood", IDS_PRINTHOOD, TRUE, TRUE, TRUE},
57 {L"Recent", L"Recent", IDS_RECENT, TRUE, TRUE, TRUE},
58 {L"SendTo", L"SendTo", IDS_SENDTO, FALSE, TRUE, TRUE},
59 {L"Templates", L"Templates", IDS_TEMPLATES, FALSE, TRUE, TRUE},
60 {L"Start Menu", L"Start Menu", IDS_STARTMENU, FALSE, TRUE, TRUE},
61 {L"Programs", L"Start Menu\\Programs", IDS_PROGRAMS, FALSE, TRUE, TRUE},
62 {L"Startup", L"Start Menu\\Programs\\Startup", IDS_STARTUP, FALSE, TRUE, TRUE},
63 {L"Local Settings", L"Local Settings", IDS_LOCALSETTINGS, TRUE, TRUE, TRUE},
64 {L"Local AppData", L"Local Settings\\Application Data", IDS_LOCALAPPDATA, TRUE, TRUE, TRUE},
65 {L"Temp", L"Local Settings\\Temp", IDS_TEMP, FALSE, FALSE, FALSE},
66 {L"Cache", L"Local Settings\\Temporary Internet Files", IDS_CACHE, FALSE, TRUE, TRUE},
67 {L"History", L"Local Settings\\History", IDS_HISTORY, FALSE, TRUE, TRUE},
68 {L"Cookies", L"Cookies", IDS_COOKIES, FALSE, TRUE, TRUE},
69 {NULL, NULL, -1, FALSE, FALSE, FALSE}
70 };
71
72
73 static FOLDERDATA
74 CommonShellFolders[] =
75 {
76 {L"Common AppData", L"Application Data", IDS_APPDATA, TRUE, TRUE, TRUE},
77 {L"Common Desktop", L"Desktop", IDS_DESKTOP, FALSE, TRUE, TRUE},
78 {L"Common Favorites", L"Favorites", IDS_FAVORITES, FALSE, TRUE, TRUE},
79 {L"Common Start Menu", L"Start Menu", IDS_STARTMENU, FALSE, TRUE, TRUE},
80 {L"Common Programs", L"Start Menu\\Programs", IDS_PROGRAMS, FALSE, TRUE, TRUE},
81 {L"Common Administrative Tools", L"Start Menu\\Programs\\Administrative Tools", IDS_ADMINTOOLS, FALSE, TRUE, FALSE},
82 {L"Common Startup", L"Start Menu\\Programs\\Startup", IDS_STARTUP, FALSE, TRUE, TRUE},
83 {L"Common Templates", L"Templates", IDS_TEMPLATES, TRUE, TRUE, TRUE},
84 {L"Common Documents", L"My Documents", IDS_MYDOCUMENTS, FALSE, TRUE, TRUE},
85 {L"CommonPictures", L"My Documents\\My Pictures", IDS_MYPICTURES, FALSE, TRUE, TRUE},
86 {L"CommonMusic", L"My Documents\\My Music", IDS_MYMUSIC, FALSE, TRUE, TRUE},
87 {L"CommonVideo", L"My Documents\\My Videos", IDS_MYVIDEOS, FALSE, TRUE, TRUE},
88 {NULL, NULL, -1, FALSE, FALSE, FALSE}
89 };
90
91
92 void
93 DebugPrint(char* fmt,...)
94 {
95 char buffer[512];
96 va_list ap;
97
98 va_start(ap, fmt);
99 vsprintf(buffer, fmt, ap);
100 va_end(ap);
101
102 OutputDebugStringA(buffer);
103 }
104
105
106 BOOL WINAPI
107 InitializeProfiles (VOID)
108 {
109 WCHAR szProfilesPath[MAX_PATH];
110 WCHAR szProfilePath[MAX_PATH];
111 WCHAR szBuffer[MAX_PATH];
112 DWORD dwLength;
113 PFOLDERDATA lpFolderData;
114 HKEY hKey;
115 LONG Error;
116
117 /* Load profiles directory path */
118 if (!LoadStringW(hInstance,
119 IDS_PROFILEPATH,
120 szBuffer,
121 MAX_PATH))
122 {
123 DPRINT1("Error: %lu\n", GetLastError());
124 return FALSE;
125 }
126
127 Error = RegOpenKeyExW (HKEY_LOCAL_MACHINE,
128 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
129 0,
130 KEY_ALL_ACCESS,
131 &hKey);
132 if (Error != ERROR_SUCCESS)
133 {
134 DPRINT1("Error: %lu\n", Error);
135 SetLastError((DWORD)Error);
136 return FALSE;
137 }
138
139 /* Store profiles directory path */
140 dwLength = (wcslen (szBuffer) + 1) * sizeof(WCHAR);
141 Error = RegSetValueExW (hKey,
142 L"ProfilesDirectory",
143 0,
144 REG_EXPAND_SZ,
145 (LPBYTE)szBuffer,
146 dwLength);
147 if (Error != ERROR_SUCCESS)
148 {
149 DPRINT1("Error: %lu\n", Error);
150 RegCloseKey (hKey);
151 SetLastError((DWORD)Error);
152 return FALSE;
153 }
154
155 /* Expand it */
156 if (!ExpandEnvironmentStringsW (szBuffer,
157 szProfilesPath,
158 MAX_PATH))
159 {
160 DPRINT1("Error: %lu\n", GetLastError());
161 RegCloseKey (hKey);
162 return FALSE;
163 }
164
165 /* Create profiles directory */
166 if (!CreateDirectoryW (szProfilesPath, NULL))
167 {
168 if (GetLastError () != ERROR_ALREADY_EXISTS)
169 {
170 DPRINT1("Error: %lu\n", GetLastError());
171 RegCloseKey (hKey);
172 return FALSE;
173 }
174 }
175
176 /* Set 'DefaultUserProfile' value */
177 wcscpy (szBuffer, L"Default User");
178 if (!AppendSystemPostfix (szBuffer, MAX_PATH))
179 {
180 DPRINT1("AppendSystemPostfix() failed\n", GetLastError());
181 RegCloseKey (hKey);
182 return FALSE;
183 }
184
185 dwLength = (wcslen (szBuffer) + 1) * sizeof(WCHAR);
186 Error = RegSetValueExW (hKey,
187 L"DefaultUserProfile",
188 0,
189 REG_SZ,
190 (LPBYTE)szBuffer,
191 dwLength);
192 if (Error != ERROR_SUCCESS)
193 {
194 DPRINT1("Error: %lu\n", Error);
195 RegCloseKey (hKey);
196 SetLastError((DWORD)Error);
197 return FALSE;
198 }
199
200 RegCloseKey (hKey);
201
202 /* Create 'Default User' profile directory */
203 wcscpy (szProfilePath, szProfilesPath);
204 wcscat (szProfilePath, L"\\");
205 wcscat (szProfilePath, szBuffer);
206 if (!CreateDirectoryW (szProfilePath, NULL))
207 {
208 if (GetLastError () != ERROR_ALREADY_EXISTS)
209 {
210 DPRINT1("Error: %lu\n", GetLastError());
211 return FALSE;
212 }
213 }
214
215 /* Set current user profile */
216 SetEnvironmentVariableW(L"USERPROFILE", szProfilePath);
217
218 /* Create 'Default User' subdirectories */
219 /* FIXME: Get these paths from the registry */
220 lpFolderData = &UserShellFolders[0];
221 while (lpFolderData->lpValueName != NULL)
222 {
223 wcscpy(szBuffer, szProfilePath);
224 wcscat(szBuffer, L"\\");
225
226 /* Append the folder name */
227 dwLength = wcslen(szBuffer);
228 if (!LoadStringW(hInstance,
229 lpFolderData->uId,
230 &szBuffer[dwLength],
231 MAX_PATH - dwLength))
232 {
233 /* Use the default name instead */
234 wcscat(szBuffer, lpFolderData->lpPath);
235 }
236
237 if (!CreateDirectoryW(szBuffer, NULL))
238 {
239 if (GetLastError() != ERROR_ALREADY_EXISTS)
240 {
241 DPRINT1("Error: %lu\n", GetLastError());
242 return FALSE;
243 }
244 }
245
246 if (lpFolderData->bHidden == TRUE)
247 {
248 SetFileAttributesW(szBuffer,
249 FILE_ATTRIBUTE_HIDDEN);
250 }
251
252 lpFolderData++;
253 }
254
255 /* Set default 'Shell Folders' values */
256 Error = RegOpenKeyExW(HKEY_USERS,
257 L".Default\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
258 0,
259 KEY_ALL_ACCESS,
260 &hKey);
261 if (Error != ERROR_SUCCESS)
262 {
263 DPRINT1("Error: %lu\n", Error);
264 SetLastError((DWORD)Error);
265 return FALSE;
266 }
267
268 lpFolderData = &UserShellFolders[0];
269 while (lpFolderData->lpValueName != NULL)
270 {
271 if (lpFolderData->bShellFolder)
272 {
273 wcscpy(szBuffer, szProfilePath);
274 wcscat(szBuffer, L"\\");
275
276 /* Append the folder name */
277 dwLength = wcslen(szBuffer);
278 if (!LoadStringW(hInstance,
279 lpFolderData->uId,
280 &szBuffer[dwLength],
281 MAX_PATH - dwLength))
282 {
283 /* Use the default name instead */
284 wcscat(szBuffer, lpFolderData->lpPath);
285 }
286
287 dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
288 Error = RegSetValueExW(hKey,
289 lpFolderData->lpValueName,
290 0,
291 REG_SZ,
292 (LPBYTE)szBuffer,
293 dwLength);
294 if (Error != ERROR_SUCCESS)
295 {
296 DPRINT1("Error: %lu\n", Error);
297 RegCloseKey(hKey);
298 SetLastError((DWORD)Error);
299 return FALSE;
300 }
301 }
302
303 lpFolderData++;
304 }
305
306 /* Set 'Fonts' folder path */
307 GetWindowsDirectoryW(szBuffer, MAX_PATH);
308 wcscat(szBuffer, L"\\media\\fonts");
309
310 dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
311 Error = RegSetValueExW(hKey,
312 L"Fonts",
313 0,
314 REG_SZ,
315 (LPBYTE)szBuffer,
316 dwLength);
317 if (Error != ERROR_SUCCESS)
318 {
319 DPRINT1("Error: %lu\n", Error);
320 RegCloseKey(hKey);
321 SetLastError((DWORD)Error);
322 return FALSE;
323 }
324
325 RegCloseKey(hKey);
326
327 /* Set default 'User Shell Folders' values */
328 Error = RegOpenKeyExW(HKEY_USERS,
329 L".Default\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders",
330 0,
331 KEY_ALL_ACCESS,
332 &hKey);
333 if (Error != ERROR_SUCCESS)
334 {
335 DPRINT1("Error: %lu\n", Error);
336 SetLastError((DWORD)Error);
337 return FALSE;
338 }
339
340 lpFolderData = &UserShellFolders[0];
341 while (lpFolderData->lpValueName != NULL)
342 {
343 if (lpFolderData->bUserShellFolder)
344 {
345 wcscpy(szBuffer, L"%USERPROFILE%\\");
346
347 /* Append the folder name */
348 dwLength = wcslen(szBuffer);
349 if (!LoadStringW(hInstance,
350 lpFolderData->uId,
351 &szBuffer[dwLength],
352 MAX_PATH - dwLength))
353 {
354 /* Use the default name instead */
355 wcscat(szBuffer, lpFolderData->lpPath);
356 }
357
358 dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
359 Error = RegSetValueExW(hKey,
360 lpFolderData->lpValueName,
361 0,
362 REG_EXPAND_SZ,
363 (LPBYTE)szBuffer,
364 dwLength);
365 if (Error != ERROR_SUCCESS)
366 {
367 DPRINT1("Error: %lu\n", Error);
368 RegCloseKey(hKey);
369 SetLastError((DWORD)Error);
370 return FALSE;
371 }
372 }
373
374 lpFolderData++;
375 }
376
377 RegCloseKey(hKey);
378
379
380 /* Set 'AllUsersProfile' value */
381 wcscpy(szBuffer, L"All Users");
382 if (!AppendSystemPostfix(szBuffer, MAX_PATH))
383 {
384 DPRINT1("AppendSystemPostfix() failed\n", GetLastError());
385 return FALSE;
386 }
387
388 Error = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
389 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList",
390 0,
391 KEY_ALL_ACCESS,
392 &hKey);
393 if (Error != ERROR_SUCCESS)
394 {
395 DPRINT1("Error: %lu\n", Error);
396 SetLastError((DWORD)Error);
397 return FALSE;
398 }
399
400 dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
401 Error = RegSetValueExW(hKey,
402 L"AllUsersProfile",
403 0,
404 REG_SZ,
405 (LPBYTE)szBuffer,
406 dwLength);
407 if (Error != ERROR_SUCCESS)
408 {
409 DPRINT1("Error: %lu\n", Error);
410 RegCloseKey (hKey);
411 SetLastError((DWORD)Error);
412 return FALSE;
413 }
414
415 RegCloseKey(hKey);
416
417
418 /* Create 'All Users' profile directory */
419 wcscpy(szProfilePath, szProfilesPath);
420 wcscat(szProfilePath, L"\\");
421 wcscat(szProfilePath, szBuffer);
422 if (!CreateDirectoryW(szProfilePath, NULL))
423 {
424 if (GetLastError() != ERROR_ALREADY_EXISTS)
425 {
426 DPRINT1("Error: %lu\n", GetLastError());
427 return FALSE;
428 }
429 }
430
431 /* Set 'All Users' profile */
432 SetEnvironmentVariableW(L"ALLUSERSPROFILE", szProfilePath);
433
434 /* Create 'All Users' subdirectories */
435 /* FIXME: Take these paths from the registry */
436 lpFolderData = &CommonShellFolders[0];
437 while (lpFolderData->lpValueName != NULL)
438 {
439 wcscpy(szBuffer, szProfilePath);
440 wcscat(szBuffer, L"\\");
441
442 /* Append the folder name */
443 dwLength = wcslen(szBuffer);
444 if (!LoadStringW(hInstance,
445 lpFolderData->uId,
446 &szBuffer[dwLength],
447 MAX_PATH - dwLength))
448 {
449 /* Use the default name instead */
450 wcscat(szBuffer, lpFolderData->lpPath);
451 }
452
453 if (!CreateDirectoryW(szBuffer, NULL))
454 {
455 if (GetLastError() != ERROR_ALREADY_EXISTS)
456 {
457 DPRINT1("Error: %lu\n", GetLastError());
458 return FALSE;
459 }
460 }
461
462 if (lpFolderData->bHidden)
463 {
464 SetFileAttributesW(szBuffer,
465 FILE_ATTRIBUTE_HIDDEN);
466 }
467
468 lpFolderData++;
469 }
470
471 /* Set common 'Shell Folders' values */
472 Error = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
473 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
474 0,
475 KEY_ALL_ACCESS,
476 &hKey);
477 if (Error != ERROR_SUCCESS)
478 {
479 DPRINT1("Error: %lu\n", Error);
480 SetLastError((DWORD)Error);
481 return FALSE;
482 }
483
484 lpFolderData = &CommonShellFolders[0];
485 while (lpFolderData->lpValueName != NULL)
486 {
487 if (lpFolderData->bShellFolder)
488 {
489 wcscpy(szBuffer, szProfilePath);
490 wcscat(szBuffer, L"\\");
491
492 /* Append the folder name */
493 dwLength = wcslen(szBuffer);
494 if (!LoadStringW(hInstance,
495 lpFolderData->uId,
496 &szBuffer[dwLength],
497 MAX_PATH - dwLength))
498 {
499 /* Use the default name instead */
500 wcscat(szBuffer, lpFolderData->lpPath);
501 }
502
503 dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
504 Error = RegSetValueExW(hKey,
505 lpFolderData->lpValueName,
506 0,
507 REG_SZ,
508 (LPBYTE)szBuffer,
509 dwLength);
510 if (Error != ERROR_SUCCESS)
511 {
512 DPRINT1("Error: %lu\n", Error);
513 RegCloseKey(hKey);
514 SetLastError((DWORD)Error);
515 return FALSE;
516 }
517 }
518
519 lpFolderData++;
520 }
521
522 RegCloseKey(hKey);
523
524 /* Set common 'User Shell Folders' values */
525 Error = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
526 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders",
527 0,
528 KEY_ALL_ACCESS,
529 &hKey);
530 if (Error != ERROR_SUCCESS)
531 {
532 DPRINT1("Error: %lu\n", Error);
533 SetLastError((DWORD)Error);
534 return FALSE;
535 }
536
537 lpFolderData = &CommonShellFolders[0];
538 while (lpFolderData->lpValueName != NULL)
539 {
540 if (lpFolderData->bUserShellFolder)
541 {
542 wcscpy(szBuffer, L"%ALLUSERSPROFILE%\\");
543
544 /* Append the folder name */
545 dwLength = wcslen(szBuffer);
546 if (!LoadStringW(hInstance,
547 lpFolderData->uId,
548 &szBuffer[dwLength],
549 MAX_PATH - dwLength))
550 {
551 /* Use the default name instead */
552 wcscat(szBuffer, lpFolderData->lpPath);
553 }
554
555 dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
556 Error = RegSetValueExW(hKey,
557 lpFolderData->lpValueName,
558 0,
559 REG_EXPAND_SZ,
560 (LPBYTE)szBuffer,
561 dwLength);
562 if (Error != ERROR_SUCCESS)
563 {
564 DPRINT1("Error: %lu\n", Error);
565 RegCloseKey(hKey);
566 SetLastError((DWORD)Error);
567 return FALSE;
568 }
569 }
570
571 lpFolderData++;
572 }
573
574 RegCloseKey(hKey);
575
576 /* Load 'Program Files' location */
577 if (!LoadStringW(hInstance,
578 IDS_PROGRAMFILES,
579 szBuffer,
580 MAX_PATH))
581 {
582 DPRINT1("Error: %lu\n", GetLastError());
583 return FALSE;
584 }
585
586 /* Expand it */
587 if (!ExpandEnvironmentStringsW (szBuffer,
588 szProfilesPath,
589 MAX_PATH))
590 {
591 DPRINT1("Error: %lu\n", GetLastError());
592 RegCloseKey (hKey);
593 return FALSE;
594 }
595
596 /* Store it */
597 Error = RegOpenKeyExW (HKEY_LOCAL_MACHINE,
598 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion",
599 0,
600 KEY_ALL_ACCESS,
601 &hKey);
602 if (Error != ERROR_SUCCESS)
603 {
604 DPRINT1("Error: %lu\n", Error);
605 SetLastError((DWORD)Error);
606 return FALSE;
607 }
608
609 dwLength = (wcslen (szProfilesPath) + 1) * sizeof(WCHAR);
610 Error = RegSetValueExW (hKey,
611 L"ProgramFilesDir",
612 0,
613 REG_SZ,
614 (LPBYTE)szProfilesPath,
615 dwLength);
616 if (Error != ERROR_SUCCESS)
617 {
618 DPRINT1("Error: %lu\n", Error);
619 RegCloseKey (hKey);
620 SetLastError((DWORD)Error);
621 return FALSE;
622 }
623
624 RegCloseKey (hKey);
625
626 /* Create directory */
627 if (!CreateDirectoryW (szProfilesPath, NULL))
628 {
629 if (GetLastError () != ERROR_ALREADY_EXISTS)
630 {
631 DPRINT1("Error: %lu\n", GetLastError());
632 return FALSE;
633 }
634 }
635
636
637 DPRINT("Success\n");
638
639 return TRUE;
640 }
641
642
643 BOOL
644 UpdateUsersShellFolderSettings(LPCWSTR lpUserProfilePath,
645 HKEY hUserKey)
646 {
647 WCHAR szBuffer[MAX_PATH];
648 DWORD dwLength;
649 PFOLDERDATA lpFolderData;
650 HKEY hFoldersKey;
651 LONG Error;
652
653 DPRINT("UpdateUsersShellFolderSettings() called\n");
654
655 DPRINT("User profile path: %S\n", lpUserProfilePath);
656
657 Error = RegOpenKeyExW(hUserKey,
658 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
659 0,
660 KEY_ALL_ACCESS,
661 &hFoldersKey);
662 if (Error != ERROR_SUCCESS)
663 {
664 DPRINT1("Error: %lu\n", Error);
665 SetLastError((DWORD)Error);
666 return FALSE;
667 }
668
669 lpFolderData = &UserShellFolders[0];
670 while (lpFolderData->lpValueName != NULL)
671 {
672 if (lpFolderData->bShellFolder)
673 {
674 wcscpy(szBuffer, lpUserProfilePath);
675 wcscat(szBuffer, L"\\");
676
677 /* Append the folder name */
678 dwLength = wcslen(szBuffer);
679 if (!LoadStringW(hInstance,
680 lpFolderData->uId,
681 &szBuffer[dwLength],
682 MAX_PATH - dwLength))
683 {
684 /* Use the default name instead */
685 wcscat(szBuffer, lpFolderData->lpPath);
686 }
687
688 DPRINT("%S: %S\n", lpFolderData->lpValueName, szBuffer);
689
690 dwLength = (wcslen(szBuffer) + 1) * sizeof(WCHAR);
691 Error = RegSetValueExW(hFoldersKey,
692 lpFolderData->lpValueName,
693 0,
694 REG_SZ,
695 (LPBYTE)szBuffer,
696 dwLength);
697 if (Error != ERROR_SUCCESS)
698 {
699 DPRINT1("Error: %lu\n", Error);
700 RegCloseKey(hFoldersKey);
701 SetLastError((DWORD)Error);
702 return FALSE;
703 }
704 }
705
706 lpFolderData++;
707 }
708
709 RegCloseKey(hFoldersKey);
710
711 DPRINT("UpdateUsersShellFolderSettings() done\n");
712
713 return TRUE;
714 }
715
716 /* EOF */