2003-12-07 01:12:58 +00:00
|
|
|
/*
|
|
|
|
* ReactOS applications
|
|
|
|
* Copyright (C) 2001, 2002 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.
|
|
|
|
*/
|
2005-01-06 13:58:04 +00:00
|
|
|
/* $Id$
|
2003-12-07 01:12:58 +00:00
|
|
|
*
|
|
|
|
* 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>
|
2005-04-30 19:00:46 +00:00
|
|
|
#include "resource.h"
|
2003-12-07 01:12:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* GLOBALS ******************************************************************/
|
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
|
|
|
static
|
|
|
|
BOOL GetShell(WCHAR *CommandLine)
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
DWORD Type, Size;
|
|
|
|
WCHAR Shell[MAX_PATH];
|
|
|
|
BOOL Ret = FALSE;
|
2005-05-08 04:07:56 +00:00
|
|
|
|
|
|
|
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
|
|
|
L"SOFTWARE\\ReactOS\\Windows NT\\CurrentVersion\\Winlogon",
|
2003-12-07 01:12:58 +00:00
|
|
|
0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
Size = MAX_PATH * sizeof(WCHAR);
|
|
|
|
if(RegQueryValueEx(hKey,
|
|
|
|
L"Shell",
|
|
|
|
NULL,
|
|
|
|
&Type,
|
|
|
|
(LPBYTE)Shell,
|
|
|
|
&Size) == ERROR_SUCCESS)
|
|
|
|
{
|
2003-12-27 11:09:58 +00:00
|
|
|
if((Type == REG_SZ) || (Type == REG_EXPAND_SZ))
|
2003-12-07 01:12:58 +00:00
|
|
|
{
|
|
|
|
wcscpy(CommandLine, Shell);
|
|
|
|
Ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2003-12-07 01:12:58 +00:00
|
|
|
if(!Ret)
|
|
|
|
{
|
|
|
|
if(GetWindowsDirectory(CommandLine, MAX_PATH - 13))
|
|
|
|
wcscat(CommandLine, L"\\explorer.exe");
|
|
|
|
else
|
|
|
|
wcscpy(CommandLine, L"explorer.exe");
|
|
|
|
}
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2003-12-07 01:12:58 +00:00
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
2003-12-07 01:17:28 +00:00
|
|
|
static
|
|
|
|
void StartShell(void)
|
2003-12-07 01:12:58 +00:00
|
|
|
{
|
|
|
|
STARTUPINFO si;
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
WCHAR Shell[MAX_PATH];
|
2003-12-27 11:09:58 +00:00
|
|
|
WCHAR ExpandedShell[MAX_PATH];
|
2005-04-30 19:00:46 +00:00
|
|
|
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2003-12-07 01:12:58 +00:00
|
|
|
GetShell(Shell);
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2003-12-07 01:12:58 +00:00
|
|
|
ZeroMemory(&si, sizeof(STARTUPINFO));
|
|
|
|
si.cb = sizeof(STARTUPINFO);
|
2003-12-07 01:17:28 +00:00
|
|
|
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2003-12-27 11:09:58 +00:00
|
|
|
ExpandEnvironmentStrings(Shell, ExpandedShell, MAX_PATH);
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2003-12-07 01:12:58 +00:00
|
|
|
if(CreateProcess(NULL,
|
2003-12-27 11:09:58 +00:00
|
|
|
ExpandedShell,
|
2003-12-07 01:12:58 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
NORMAL_PRIORITY_CLASS,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&si,
|
|
|
|
&pi))
|
|
|
|
{
|
2004-12-22 01:20:52 +00:00
|
|
|
WaitForSingleObject(pi.hProcess, INFINITE);
|
2003-12-07 01:12:58 +00:00
|
|
|
CloseHandle(pi.hProcess);
|
|
|
|
CloseHandle(pi.hThread);
|
|
|
|
}
|
2003-12-27 11:09:58 +00:00
|
|
|
else
|
2005-04-30 19:00:46 +00:00
|
|
|
{
|
2005-05-04 22:32:43 +00:00
|
|
|
LoadString( GetModuleHandle(NULL), STRING_USERINIT_FAIL, szMsg, sizeof(szMsg) / sizeof(szMsg[0]));
|
|
|
|
MessageBox(0, szMsg, NULL, 0);
|
2005-04-30 19:00:46 +00:00
|
|
|
}
|
2003-12-07 01:17:28 +00:00
|
|
|
}
|
|
|
|
|
2004-08-17 21:47:36 +00:00
|
|
|
static
|
|
|
|
void SetUserSettings(void)
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
DWORD Type, Size;
|
|
|
|
WCHAR szWallpaper[MAX_PATH + 1];
|
2005-05-08 04:07:56 +00:00
|
|
|
|
2004-08-17 21:47:36 +00:00
|
|
|
if(RegOpenKeyEx(HKEY_CURRENT_USER,
|
|
|
|
L"Control Panel\\Desktop",
|
|
|
|
0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
Size = sizeof(szWallpaper);
|
|
|
|
if(RegQueryValueEx(hKey,
|
|
|
|
L"Wallpaper",
|
|
|
|
NULL,
|
|
|
|
&Type,
|
|
|
|
(LPBYTE)szWallpaper,
|
|
|
|
&Size) == ERROR_SUCCESS
|
|
|
|
&& Type == REG_SZ)
|
|
|
|
{
|
2004-08-17 21:49:51 +00:00
|
|
|
/* Load and change the wallpaper */
|
2004-08-17 21:47:36 +00:00
|
|
|
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, szWallpaper, SPIF_SENDCHANGE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-08-17 21:49:51 +00:00
|
|
|
/* remove the wallpaper */
|
2004-08-17 21:47:36 +00:00
|
|
|
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, NULL, SPIF_SENDCHANGE);
|
|
|
|
}
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-07 01:17:28 +00:00
|
|
|
int WINAPI
|
|
|
|
WinMain(HINSTANCE hInst,
|
|
|
|
HINSTANCE hPrevInstance,
|
|
|
|
LPSTR lpszCmdLine,
|
|
|
|
int nCmdShow)
|
|
|
|
{
|
2004-08-17 21:47:36 +00:00
|
|
|
SetUserSettings();
|
2003-12-07 01:17:28 +00:00
|
|
|
StartShell();
|
2003-12-07 01:12:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|