added userinit application
[reactos.git] / reactos / subsys / system / userinit / userinit.c
1 /*
2 * ReactOS applications
3 * Copyright (C) 2001, 2002 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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id: userinit.c,v 1.1 2003/12/07 01:12:58 weiden Exp $
20 *
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS Userinit Logon Application
23 * FILE: subsys/system/userinit/userinit.c
24 * PROGRAMMERS: Thomas Weidenmueller (w3seek@users.sourceforge.net)
25 */
26 #include <windows.h>
27
28
29 /* GLOBALS ******************************************************************/
30
31 /* FUNCTIONS ****************************************************************/
32
33 static
34 BOOL GetShell(WCHAR *CommandLine)
35 {
36 HKEY hKey;
37 DWORD Type, Size;
38 WCHAR Shell[MAX_PATH];
39 BOOL Ret = FALSE;
40
41 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
42 L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
43 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
44 {
45 Size = MAX_PATH * sizeof(WCHAR);
46 if(RegQueryValueEx(hKey,
47 L"Shell",
48 NULL,
49 &Type,
50 (LPBYTE)Shell,
51 &Size) == ERROR_SUCCESS)
52 {
53 if(Type == REG_SZ)
54 {
55 wcscpy(CommandLine, Shell);
56 Ret = TRUE;
57 }
58 }
59 RegCloseKey(hKey);
60 }
61
62 if(!Ret)
63 {
64 if(GetWindowsDirectory(CommandLine, MAX_PATH - 13))
65 wcscat(CommandLine, L"\\explorer.exe");
66 else
67 wcscpy(CommandLine, L"explorer.exe");
68 }
69
70 return Ret;
71 }
72
73 int WINAPI
74 WinMain(HINSTANCE hInst,
75 HINSTANCE hPrevInstance,
76 LPSTR lpszCmdLine,
77 int nCmdShow)
78 {
79 STARTUPINFO si;
80 PROCESS_INFORMATION pi;
81 WCHAR Shell[MAX_PATH];
82
83 GetShell(Shell);
84
85 ZeroMemory(&si, sizeof(STARTUPINFO));
86 si.cb = sizeof(STARTUPINFO);
87
88 if(CreateProcess(NULL,
89 Shell,
90 NULL,
91 NULL,
92 FALSE,
93 NORMAL_PRIORITY_CLASS,
94 NULL,
95 NULL,
96 &si,
97 &pi))
98 {
99 CloseHandle(pi.hProcess);
100 CloseHandle(pi.hThread);
101 }
102
103 return 0;
104 }
105
106 /* EOF */