- Add proper file header.
authorEric Kohl <eric.kohl@reactos.org>
Thu, 30 Sep 2004 20:23:00 +0000 (20:23 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 30 Sep 2004 20:23:00 +0000 (20:23 +0000)
- Create common shell folder registry values in InitializeProfiles().

svn path=/trunk/; revision=11134

reactos/lib/userenv/desktop.c
reactos/lib/userenv/directory.c
reactos/lib/userenv/environment.c
reactos/lib/userenv/internal.h
reactos/lib/userenv/misc.c
reactos/lib/userenv/profile.c
reactos/lib/userenv/registry.c
reactos/lib/userenv/setup.c
reactos/lib/userenv/userenv.c

index 8d62884..d8c2619 100644 (file)
@@ -1,4 +1,22 @@
-/* $Id: desktop.c,v 1.10 2004/09/06 12:00:40 ekohl Exp $
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 2004 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* $Id: desktop.c,v 1.11 2004/09/30 20:23:00 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
index c916736..9436974 100644 (file)
@@ -1,4 +1,22 @@
-/* $Id: directory.c,v 1.5 2004/08/15 19:02:40 chorns Exp $
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 2004 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* $Id: directory.c,v 1.6 2004/09/30 20:23:00 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
index f4dd3b2..4a6f0be 100644 (file)
@@ -1,4 +1,22 @@
-/* $Id: environment.c,v 1.6 2004/08/15 19:02:40 chorns Exp $
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 2004 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* $Id: environment.c,v 1.7 2004/09/30 20:23:00 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
index f540e19..296c213 100644 (file)
@@ -1,4 +1,22 @@
-/* $Id: internal.h,v 1.8 2004/07/12 10:33:04 weiden Exp $ 
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 2004 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* $Id: internal.h,v 1.9 2004/09/30 20:23:00 ekohl Exp $ 
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
index e4c6e9d..89ff363 100644 (file)
@@ -1,4 +1,22 @@
-/* $Id: misc.c,v 1.6 2004/08/15 19:02:40 chorns Exp $
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 2004 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* $Id: misc.c,v 1.7 2004/09/30 20:23:00 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -101,53 +119,56 @@ DYN_MODULE DynOle32 =
   }
 };
 
-/*
-   Use this function to load functions from other modules. We cannot statically
-   link to e.g. ole32.dll because those dlls would get loaded on startup with
-   winlogon and they may try to register classes etc when not even a window station
-   has been created!
-*/
 
+/*
+ * Use this function to load functions from other modules. We cannot statically
+ * link to e.g. ole32.dll because those dlls would get loaded on startup with
+ * winlogon and they may try to register classes etc when not even a window station
+ * has been created!
+ */
 BOOL
 LoadDynamicImports(PDYN_MODULE Module, PDYN_FUNCS DynFuncs)
 {
   LPSTR *fname;
   PVOID *fn;
-  
+
   ZeroMemory(DynFuncs, sizeof(DYN_FUNCS));
-  
+
   DynFuncs->hModule = LoadLibraryW(Module->Library);
-  if(!DynFuncs->hModule)
-  {
-    return FALSE;
-  }
-  
+  if (!DynFuncs->hModule)
+    {
+      return FALSE;
+    }
+
   fn = &DynFuncs->fn.foo;
-  
+
   /* load the imports */
-  for(fname = Module->Functions; *fname != NULL; fname++)
-  {
-    *fn = GetProcAddress(DynFuncs->hModule, *fname);
-    if(*fn == NULL)
+  for (fname = Module->Functions; *fname != NULL; fname++)
     {
-      FreeLibrary(DynFuncs->hModule);
-      DynFuncs->hModule = (HMODULE)0;
-      return FALSE;
+      *fn = GetProcAddress(DynFuncs->hModule, *fname);
+      if (*fn == NULL)
+        {
+          FreeLibrary(DynFuncs->hModule);
+          DynFuncs->hModule = (HMODULE)0;
+
+          return FALSE;
+        }
+
+      fn++;
     }
-    fn++;
-  }
-  
+
   return TRUE;
 }
 
+
 VOID
 UnloadDynamicImports(PDYN_FUNCS DynFuncs)
 {
-  if(DynFuncs->hModule)
-  {
-    FreeLibrary(DynFuncs->hModule);
-    DynFuncs->hModule = (HMODULE)0;
-  }
+  if (DynFuncs->hModule)
+    {
+      FreeLibrary(DynFuncs->hModule);
+      DynFuncs->hModule = (HMODULE)0;
+    }
 }
 
 /* EOF */
index 4cbc8ff..6c82828 100644 (file)
@@ -1,4 +1,22 @@
-/* $Id: profile.c,v 1.12 2004/08/15 19:02:40 chorns Exp $
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 2004 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* $Id: profile.c,v 1.13 2004/09/30 20:23:00 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
index ca3ee56..25f312e 100644 (file)
@@ -1,4 +1,22 @@
-/* $Id: registry.c,v 1.5 2004/08/15 19:02:40 chorns Exp $
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 2004 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* $Id: registry.c,v 1.6 2004/09/30 20:23:00 ekohl Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
index 605745d..7cb001a 100644 (file)
@@ -1,4 +1,22 @@
-/* $Id: setup.c,v 1.6 2004/08/15 19:02:40 chorns Exp $ 
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 2004 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  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.7 2004/09/30 20:23:00 ekohl Exp $ 
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -16,6 +34,13 @@ typedef struct _DIRDATA
   LPWSTR DirName;
 } DIRDATA, *PDIRDATA;
 
+typedef struct _REGDATA
+{
+  LPWSTR ValueName;
+  LPWSTR ValueData;
+} REGDATA, *PREGDATA;
+
+
 
 static DIRDATA
 DefaultUserDirectories[] =
@@ -52,6 +77,27 @@ AllUsersDirectories[] =
 };
 
 
+static REGDATA
+CommonShellFolders[] =
+{
+  {L"Desktop", L"%ALLUSERSPROFILE%\\Desktop"},
+  {L"Common AppData", L"%ALLUSERSPROFILE%\\Application Data"},
+  {L"Common Programs", L"%ALLUSERSPROFILE%\\Start Menu\\Programs"},
+  {L"Common Documents", L"%ALLUSERSPROFILE%\\Documents"},
+  {L"Common Desktop", L"%ALLUSERSPROFILE%\\Desktop"},
+  {L"Common Start Menu", L"%ALLUSERSPROFILE%\\Start Menu"},
+  {L"CommonPictures", L"%ALLUSERSPROFILE%\\Documents\\My Pictures"},
+  {L"CommonMusic", L"%ALLUSERSPROFILE%\\Documents\\My Music"},
+  {L"CommonVideo", L"%ALLUSERSPROFILE%\\Documents\\My Videos"},
+  {L"Common Favorites", L"%ALLUSERSPROFILE%\\Favorites"},
+  {L"Common Startup", L"%ALLUSERSPROFILE%\\Start Menu\\Programs\\Startup"},
+  {L"Common Administrative Tools", L"%ALLUSERSPROFILE%\\Start Menu\\Programs\\Administrative Tools"},
+  {L"Common Templates", L"%ALLUSERSPROFILE%\\Templates"},
+  {L"Personal", L"%ALLUSERSPROFILE%\\My Documents"},
+  {NULL, NULL}
+};
+
+
 void
 DebugPrint(char* fmt,...)
 {
@@ -75,6 +121,7 @@ InitializeProfiles (VOID)
   LPWSTR lpszPtr;
   DWORD dwLength;
   PDIRDATA lpDirData;
+  PREGDATA lpRegData;
 
   HKEY hKey;
 
@@ -211,6 +258,9 @@ InitializeProfiles (VOID)
       return FALSE;
     }
 
+  RegCloseKey (hKey);
+
+
   /* Create 'All Users' profile directory */
   wcscpy (szProfilePath, szProfilesPath);
   wcscat (szProfilePath, L"\\");
@@ -255,7 +305,46 @@ InitializeProfiles (VOID)
       lpDirData++;
     }
 
-  RegCloseKey (hKey);
+  /* Create common shell folder registry values */
+  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+                   L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
+                   0,
+                   KEY_ALL_ACCESS,
+                   &hKey))
+    {
+      DPRINT1("Error: %lu\n", GetLastError());
+      return FALSE;
+    }
+
+  lpRegData = &CommonShellFolders[0];
+  while (lpRegData->ValueName != NULL)
+    {
+      if (!ExpandEnvironmentStringsW(lpRegData->ValueData,
+                                    szBuffer,
+                                    MAX_PATH))
+       {
+         DPRINT1("Error: %lu\n", GetLastError());
+         RegCloseKey(hKey);
+         return FALSE;
+       }
+
+      dwLength = (wcslen (szBuffer) + 1) * sizeof(WCHAR);
+      if (RegSetValueExW(hKey,
+                        lpRegData->ValueName,
+                        0,
+                        REG_SZ,
+                        (LPBYTE)szBuffer,
+                        dwLength))
+       {
+         DPRINT1("Error: %lu\n", GetLastError());
+         RegCloseKey(hKey);
+         return FALSE;
+       }
+
+      lpRegData++;
+    }
+
+  RegCloseKey(hKey);
 
   DPRINT1("Success\n");
 
index 229b96e..8a74d60 100644 (file)
@@ -1,4 +1,22 @@
-/* $Id: userenv.c,v 1.3 2004/08/15 19:02:40 chorns Exp $ 
+/*
+ *  ReactOS kernel
+ *  Copyright (C) 2004 ReactOS Team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/* $Id: userenv.c,v 1.4 2004/09/30 20:23:00 ekohl Exp $ 
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries