ReactOS 0.4.15-dev-7924-g5949c20
registry.c
Go to the documentation of this file.
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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19/*
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS system libraries
22 * FILE: dll/win32/userenv/registry.c
23 * PURPOSE: User profile code
24 * PROGRAMMER: Eric Kohl
25 */
26
27#include "precomp.h"
28
29#define NDEBUG
30#include <debug.h>
31
33
34/* FUNCTIONS ***************************************************************/
35
36static
37BOOL
38CopyKey(HKEY hDstKey,
39 HKEY hSrcKey)
40{
41 LONG Error;
42
43 Error = RegCopyTreeW(hSrcKey,
44 NULL,
45 hDstKey);
46 if (Error != ERROR_SUCCESS)
47 {
49 return FALSE;
50 }
51
52 return TRUE;
53}
54
55
56BOOL
58 LPCWSTR lpProfilePath)
59{
60 HKEY hDefaultKey = NULL;
61 HKEY hUserKey = NULL;
62 LONG Error;
63 BOOL Ret = FALSE;
64
65 DPRINT("CreateUserHive(%S) called\n", lpKeyName);
66
68 L".Default",
69 0,
71 &hDefaultKey);
72 if (Error != ERROR_SUCCESS)
73 {
75 goto Cleanup;
76 }
77
79 lpKeyName,
80 0,
82 &hUserKey);
83 if (Error != ERROR_SUCCESS)
84 {
86 goto Cleanup;
87 }
88
89 if (!CopyKey(hUserKey, hDefaultKey))
90 {
91 goto Cleanup;
92 }
93
94 if (!UpdateUsersShellFolderSettings(lpProfilePath,
95 hUserKey))
96 {
97 goto Cleanup;
98 }
99
100 RegFlushKey(hUserKey);
101 Ret = TRUE;
102
103Cleanup:
104 if (hUserKey != NULL)
105 RegCloseKey (hUserKey);
106
107 if (hDefaultKey != NULL)
108 RegCloseKey (hDefaultKey);
109
110 return Ret;
111}
112
113/* EOF */
BOOL Error
Definition: chkdsk.c:66
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegFlushKey(HKEY hKey)
Definition: reg.c:2951
#define SetLastError(x)
Definition: compat.h:752
BOOL UpdateUsersShellFolderSettings(LPCWSTR lpUserProfilePath, HKEY hUserKey)
Definition: setup.c:434
LSTATUS WINAPI RegCopyTreeW(_In_ HKEY, _In_opt_ LPCWSTR, _In_ HKEY)
BOOL CreateUserHive(LPCWSTR lpKeyName, LPCWSTR lpProfilePath)
Definition: registry.c:57
static BOOL CopyKey(HKEY hDstKey, HKEY hSrcKey)
Definition: registry.c:38
static const WCHAR Cleanup[]
Definition: register.c:80
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_READ
Definition: nt_native.h:1023
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#define DPRINT
Definition: sndvol32.h:71
#define WINAPI
Definition: msvc.h:6
#define HKEY_USERS
Definition: winreg.h:13
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185