Update a new users private shell folder paths when a new user profile is created.

svn path=/trunk/; revision=11164
This commit is contained in:
Eric Kohl 2004-10-03 09:27:22 +00:00
parent 772a37758e
commit d8ea61531d
4 changed files with 96 additions and 16 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: internal.h,v 1.9 2004/09/30 20:23:00 ekohl Exp $ /* $Id: internal.h,v 1.10 2004/10/03 09:27:22 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -98,7 +98,13 @@ AppendSystemPostfix (LPWSTR lpName,
/* registry.c */ /* registry.c */
BOOL BOOL
CreateUserHive (LPCWSTR lpKeyName); CreateUserHive (LPCWSTR lpKeyName,
LPCWSTR lpProfilePath);
/* setup.c */
BOOL
UpdateUsersShellFolderSettings(LPCWSTR lpUserProfilePath,
HKEY hUserKey);
#endif /* _INTERNAL_H */ #endif /* _INTERNAL_H */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: profile.c,v 1.13 2004/09/30 20:23:00 ekohl Exp $ /* $Id: profile.c,v 1.14 2004/10/03 09:27:22 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -282,12 +282,13 @@ CreateUserProfileW (PSID Sid,
RegCloseKey (hKey); RegCloseKey (hKey);
/* Create user hive name */ /* Create user hive name */
wcscat (szUserProfilePath, L"\\ntuser.dat"); wcscpy (szBuffer, szUserProfilePath);
wcscat (szBuffer, L"\\ntuser.dat");
/* Create new user hive */ /* Create new user hive */
if (RegLoadKeyW (HKEY_USERS, if (RegLoadKeyW (HKEY_USERS,
SidString.Buffer, SidString.Buffer,
szUserProfilePath)) szBuffer))
{ {
DPRINT1("Error: %lu\n", GetLastError()); DPRINT1("Error: %lu\n", GetLastError());
RtlFreeUnicodeString (&SidString); RtlFreeUnicodeString (&SidString);
@ -295,7 +296,7 @@ CreateUserProfileW (PSID Sid,
} }
/* Initialize user hive */ /* Initialize user hive */
if (!CreateUserHive (SidString.Buffer)) if (!CreateUserHive (SidString.Buffer, szUserProfilePath))
{ {
DPRINT1("Error: %lu\n", GetLastError()); DPRINT1("Error: %lu\n", GetLastError());
RtlFreeUnicodeString (&SidString); RtlFreeUnicodeString (&SidString);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: registry.c,v 1.6 2004/09/30 20:23:00 ekohl Exp $ /* $Id: registry.c,v 1.7 2004/10/03 09:27:22 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -240,11 +240,11 @@ CopyKey (HKEY hDstKey,
BOOL BOOL
CreateUserHive (LPCWSTR lpKeyName) CreateUserHive (LPCWSTR lpKeyName,
LPCWSTR lpProfilePath)
{ {
HKEY hDefaultKey; HKEY hDefaultKey;
HKEY hUserKey; HKEY hUserKey;
BOOL bResult;
DPRINT ("CreateUserHive(%S) called\n", lpKeyName); DPRINT ("CreateUserHive(%S) called\n", lpKeyName);
@ -269,8 +269,22 @@ CreateUserHive (LPCWSTR lpKeyName)
return FALSE; return FALSE;
} }
bResult = CopyKey (hUserKey, if (!CopyKey(hUserKey, hDefaultKey))
hDefaultKey); {
DPRINT1 ("Error: %lu\n", GetLastError());
RegCloseKey (hUserKey);
RegCloseKey (hDefaultKey);
return FALSE;
}
if (!UpdateUsersShellFolderSettings(lpProfilePath,
hUserKey))
{
DPRINT1("Error: %lu\n", GetLastError());
RegCloseKey (hUserKey);
RegCloseKey (hDefaultKey);
return FALSE;
}
RegFlushKey (hUserKey); RegFlushKey (hUserKey);
@ -279,7 +293,7 @@ CreateUserHive (LPCWSTR lpKeyName)
DPRINT ("CreateUserHive() done\n"); DPRINT ("CreateUserHive() done\n");
return bResult; return TRUE;
} }
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: setup.c,v 1.8 2004/10/02 12:31:28 ekohl Exp $ /* $Id: setup.c,v 1.9 2004/10/03 09:27:22 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -463,7 +463,66 @@ InitializeProfiles (VOID)
RegCloseKey(hKey); RegCloseKey(hKey);
DPRINT1("Success\n"); DPRINT("Success\n");
return TRUE;
}
BOOL
UpdateUsersShellFolderSettings(LPCWSTR lpUserProfilePath,
HKEY hUserKey)
{
WCHAR szBuffer[MAX_PATH];
DWORD dwLength;
PFOLDERDATA lpFolderData;
HKEY hFoldersKey;
DPRINT("UpdateUsersShellFolderSettings() called\n");
DPRINT("User profile path: %S\n", lpUserProfilePath);
if (RegOpenKeyExW(hUserKey,
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
0,
KEY_ALL_ACCESS,
&hFoldersKey))
{
DPRINT1("Error: %lu\n", GetLastError());
return FALSE;
}
lpFolderData = &UserShellFolders[0];
while (lpFolderData->ValueName != NULL)
{
if (lpFolderData->bShellFolder)
{
wcscpy(szBuffer, lpUserProfilePath);
wcscat(szBuffer, L"\\");
wcscat(szBuffer, lpFolderData->Path);
DPRINT("%S: %S\n", lpFolderData->ValueName, szBuffer);
dwLength = (wcslen (szBuffer) + 1) * sizeof(WCHAR);
if (RegSetValueExW(hFoldersKey,
lpFolderData->ValueName,
0,
REG_SZ,
(LPBYTE)szBuffer,
dwLength))
{
DPRINT1("Error: %lu\n", GetLastError());
RegCloseKey(hFoldersKey);
return FALSE;
}
}
lpFolderData++;
}
RegCloseKey(hFoldersKey);
DPRINT("UpdateUsersShellFolderSettings() done\n");
return TRUE; return TRUE;
} }