diff --git a/reactos/lib/userenv/En.rc b/reactos/lib/userenv/En.rc index 79b9a1bcb94..fcbc0b25657 100644 --- a/reactos/lib/userenv/En.rc +++ b/reactos/lib/userenv/En.rc @@ -43,4 +43,5 @@ BEGIN IDS_CACHE "Local Settings\\Temporary Internet Files" IDS_HISTORY "Local Settings\\History" IDS_COOKIES "Cookies" + IDS_PROGRAMFILES "%SystemDrive%\\Program Files" END diff --git a/reactos/lib/userenv/resources.h b/reactos/lib/userenv/resources.h index 4cc5d6d4137..34459c94d01 100644 --- a/reactos/lib/userenv/resources.h +++ b/reactos/lib/userenv/resources.h @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: resources.h,v 1.1 2004/10/08 11:52:30 ekohl Exp $ +/* $Id: resources.h,v 1.2 2004/10/13 18:14:07 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -48,5 +48,6 @@ #define IDS_CACHE 21 #define IDS_HISTORY 22 #define IDS_COOKIES 23 +#define IDS_PROGRAMFILES 24 /* EOF */ diff --git a/reactos/lib/userenv/setup.c b/reactos/lib/userenv/setup.c index 112d6bfdaef..e382e850fb6 100644 --- a/reactos/lib/userenv/setup.c +++ b/reactos/lib/userenv/setup.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: setup.c,v 1.11 2004/10/10 18:28:05 ekohl Exp $ +/* $Id: setup.c,v 1.12 2004/10/13 18:14:07 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -540,6 +540,62 @@ InitializeProfiles (VOID) RegCloseKey(hKey); + /* Load 'Program Files' location */ + if (!LoadString(hInstance, + IDS_PROGRAMFILES, + szBuffer, + MAX_PATH)) + { + DPRINT1("Error: %lu\n", GetLastError()); + return FALSE; + } + + /* Expand it */ + if (!ExpandEnvironmentStringsW (szBuffer, + szProfilesPath, + MAX_PATH)) + { + DPRINT1("Error: %lu\n", GetLastError()); + RegCloseKey (hKey); + return FALSE; + } + + /* Store it */ + if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion", + 0, + KEY_ALL_ACCESS, + &hKey)) + { + DPRINT1("Error: %lu\n", GetLastError()); + return FALSE; + } + + dwLength = (wcslen (szProfilesPath) + 1) * sizeof(WCHAR); + if (RegSetValueExW (hKey, + L"ProgramFilesDir", + 0, + REG_SZ, + (LPBYTE)szProfilesPath, + dwLength)) + { + DPRINT1("Error: %lu\n", GetLastError()); + RegCloseKey (hKey); + return FALSE; + } + + RegCloseKey (hKey); + + /* Create directory */ + if (!CreateDirectoryW (szProfilesPath, NULL)) + { + if (GetLastError () != ERROR_ALREADY_EXISTS) + { + DPRINT1("Error: %lu\n", GetLastError()); + return FALSE; + } + } + DPRINT("Success\n");