3 * Copyright (C) 2001, 2002 ReactOS Team
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.
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.
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.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS Userinit Logon Application
22 * FILE: subsys/system/userinit/userinit.c
23 * PROGRAMMERS: Thomas Weidenmueller (w3seek@users.sourceforge.net)
29 #define CMP_MAGIC 0x01234567
31 /* GLOBALS ******************************************************************/
33 /* FUNCTIONS ****************************************************************/
36 BOOL
GetShell(WCHAR
*CommandLine
)
40 WCHAR Shell
[MAX_PATH
];
43 if(RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
44 L
"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\Winlogon",
45 0, KEY_QUERY_VALUE
, &hKey
) == ERROR_SUCCESS
)
47 Size
= MAX_PATH
* sizeof(WCHAR
);
48 if(RegQueryValueEx(hKey
,
53 &Size
) == ERROR_SUCCESS
)
55 if((Type
== REG_SZ
) || (Type
== REG_EXPAND_SZ
))
57 wcscpy(CommandLine
, Shell
);
66 if(GetWindowsDirectory(CommandLine
, MAX_PATH
- 13))
67 wcscat(CommandLine
, L
"\\explorer.exe");
69 wcscpy(CommandLine
, L
"explorer.exe");
79 PROCESS_INFORMATION pi
;
80 WCHAR Shell
[MAX_PATH
];
81 WCHAR ExpandedShell
[MAX_PATH
];
82 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
86 ZeroMemory(&si
, sizeof(STARTUPINFO
));
87 si
.cb
= sizeof(STARTUPINFO
);
88 ZeroMemory(&pi
, sizeof(PROCESS_INFORMATION
));
90 ExpandEnvironmentStrings(Shell
, ExpandedShell
, MAX_PATH
);
92 if(CreateProcess(NULL
,
97 NORMAL_PRIORITY_CLASS
,
103 WaitForSingleObject(pi
.hProcess
, INFINITE
);
104 CloseHandle(pi
.hProcess
);
105 CloseHandle(pi
.hThread
);
109 LoadString( GetModuleHandle(NULL
), STRING_USERINIT_FAIL
, szMsg
, sizeof(szMsg
) / sizeof(szMsg
[0]));
110 MessageBox(0, szMsg
, NULL
, 0);
115 void SetUserSettings(void)
119 WCHAR szWallpaper
[MAX_PATH
+ 1];
121 if(RegOpenKeyEx(HKEY_CURRENT_USER
,
122 L
"Control Panel\\Desktop",
123 0, KEY_QUERY_VALUE
, &hKey
) == ERROR_SUCCESS
)
125 Size
= sizeof(szWallpaper
);
126 if(RegQueryValueEx(hKey
,
131 &Size
) == ERROR_SUCCESS
134 /* Load and change the wallpaper */
135 SystemParametersInfo(SPI_SETDESKWALLPAPER
, 0, szWallpaper
, SPIF_SENDCHANGE
);
139 /* remove the wallpaper */
140 SystemParametersInfo(SPI_SETDESKWALLPAPER
, 0, NULL
, SPIF_SENDCHANGE
);
147 typedef DWORD (WINAPI
*PCMP_REPORT_LOGON
)(DWORD
, DWORD
);
153 PCMP_REPORT_LOGON CMP_Report_LogOn
;
155 hModule
= LoadLibrary(L
"setupapi.dll");
158 CMP_Report_LogOn
= (PCMP_REPORT_LOGON
)GetProcAddress(hModule
, "CMP_Report_LogOn");
159 if (CMP_Report_LogOn
)
160 CMP_Report_LogOn(CMP_MAGIC
, GetCurrentProcessId());
162 FreeLibrary(hModule
);
168 #pragma warning(disable : 4100)
169 #endif /* _MSC_VER */
172 WinMain(HINSTANCE hInst
,
173 HINSTANCE hPrevInstance
,