- userinit, usetup, vmwinst, welcome, winefile, winlogon, winver.
[reactos.git] / reactos / subsys / system / userinit / userinit.c
index f973d5e..b82a698 100644 (file)
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: userinit.c,v 1.6 2004/12/22 01:20:52 navaraf Exp $
- *
+/*
  * COPYRIGHT:   See COPYING in the top level directory
  * PROJECT:     ReactOS Userinit Logon Application
  * FILE:        subsys/system/userinit/userinit.c
  * PROGRAMMERS: Thomas Weidenmueller (w3seek@users.sourceforge.net)
  */
 #include <windows.h>
+#include <cfgmgr32.h>
+#include "resource.h"
 
+#define CMP_MAGIC  0x01234567
 
 /* GLOBALS ******************************************************************/
 
@@ -37,9 +39,9 @@ BOOL GetShell(WCHAR *CommandLine)
   DWORD Type, Size;
   WCHAR Shell[MAX_PATH];
   BOOL Ret = FALSE;
-  
-  if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
-                  L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\Winlogon", 
+
+  if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+                  L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\Winlogon",
                   0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
   {
     Size = MAX_PATH * sizeof(WCHAR);
@@ -58,7 +60,7 @@ BOOL GetShell(WCHAR *CommandLine)
     }
     RegCloseKey(hKey);
   }
-  
+
   if(!Ret)
   {
     if(GetWindowsDirectory(CommandLine, MAX_PATH - 13))
@@ -66,7 +68,7 @@ BOOL GetShell(WCHAR *CommandLine)
     else
       wcscpy(CommandLine, L"explorer.exe");
   }
-  
+
   return Ret;
 }
 
@@ -77,15 +79,16 @@ void StartShell(void)
   PROCESS_INFORMATION pi;
   WCHAR Shell[MAX_PATH];
   WCHAR ExpandedShell[MAX_PATH];
-  
+  TCHAR szMsg[RC_STRING_MAX_SIZE];
+
   GetShell(Shell);
-  
+
   ZeroMemory(&si, sizeof(STARTUPINFO));
   si.cb = sizeof(STARTUPINFO);
   ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
-  
+
   ExpandEnvironmentStrings(Shell, ExpandedShell, MAX_PATH);
-  
+
   if(CreateProcess(NULL,
                    ExpandedShell,
                    NULL,
@@ -102,7 +105,10 @@ void StartShell(void)
     CloseHandle(pi.hThread);
   }
   else
-    MessageBox(0, L"Userinit failed to start the shell!\n", NULL, 0);
+  {
+    LoadString( GetModuleHandle(NULL), STRING_USERINIT_FAIL, szMsg, sizeof(szMsg) / sizeof(szMsg[0]));
+    MessageBox(0, szMsg, NULL, 0);
+  }
 }
 
 static
@@ -111,7 +117,7 @@ void SetUserSettings(void)
   HKEY hKey;
   DWORD Type, Size;
   WCHAR szWallpaper[MAX_PATH + 1];
-  
+
   if(RegOpenKeyEx(HKEY_CURRENT_USER,
                   L"Control Panel\\Desktop",
                   0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
@@ -137,12 +143,38 @@ void SetUserSettings(void)
   }
 }
 
+
+typedef DWORD (WINAPI *PCMP_REPORT_LOGON)(DWORD, DWORD);
+
+static VOID
+NotifyLogon(VOID)
+{
+    HINSTANCE hModule;
+    PCMP_REPORT_LOGON CMP_Report_LogOn;
+
+    hModule = LoadLibrary(L"setupapi.dll");
+    if (hModule)
+    {
+        CMP_Report_LogOn = (PCMP_REPORT_LOGON)GetProcAddress(hModule, "CMP_Report_LogOn");
+        if (CMP_Report_LogOn)
+            CMP_Report_LogOn(CMP_MAGIC, GetCurrentProcessId());
+
+        FreeLibrary(hModule);
+    }
+}
+
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4100)
+#endif /* _MSC_VER */
+
 int WINAPI
 WinMain(HINSTANCE hInst,
-       HINSTANCE hPrevInstance,
-       LPSTR lpszCmdLine,
-       int nCmdShow)
+        HINSTANCE hPrevInstance,
+        LPSTR lpszCmdLine,
+        int nCmdShow)
 {
+  NotifyLogon();
   SetUserSettings();
   StartShell();
   return 0;