2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Winlogon
4 * FILE: base/system/winlogon/setup.c
5 * PURPOSE: Setup support functions
6 * PROGRAMMERS: Eric Kohl
9 /* INCLUDES *****************************************************************/
13 /* FUNCTIONS ****************************************************************/
24 TRACE("GetSetupType()\n");
27 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
32 if (dwError
!= ERROR_SUCCESS
)
36 dwSize
= sizeof(DWORD
);
37 dwError
= RegQueryValueExW(hKey
,
44 /* Close key, and check if returned values are correct */
46 if (dwError
!= ERROR_SUCCESS
|| dwType
!= REG_DWORD
|| dwSize
!= sizeof(DWORD
))
49 TRACE("GetSetupType() returns %lu\n", dwSetupType
);
58 IN LPVOID lpParameter
)
60 PROCESS_INFORMATION ProcessInformation
;
61 STARTUPINFOW StartupInfo
;
62 WCHAR Shell
[MAX_PATH
];
63 WCHAR CommandLine
[MAX_PATH
];
71 TRACE("RunSetup() called\n");
74 dwError
= RegOpenKeyExW(HKEY_LOCAL_MACHINE
,
79 if (dwError
!= ERROR_SUCCESS
)
83 dwSize
= sizeof(Shell
);
84 dwError
= RegQueryValueExW(hKey
,
91 if (dwError
!= ERROR_SUCCESS
)
95 Shell
[dwSize
/ sizeof(WCHAR
)] = UNICODE_NULL
;
97 /* Expand string (if applicable) */
98 if (dwType
== REG_EXPAND_SZ
)
99 ExpandEnvironmentStringsW(Shell
, CommandLine
, ARRAYSIZE(CommandLine
));
100 else if (dwType
== REG_SZ
)
101 wcscpy(CommandLine
, Shell
);
105 TRACE("Should run '%s' now\n", debugstr_w(CommandLine
));
107 SwitchDesktop(WLSession
->ApplicationDesktop
);
110 StartupInfo
.cb
= sizeof(StartupInfo
);
111 StartupInfo
.lpReserved
= NULL
;
112 StartupInfo
.lpDesktop
= L
"WinSta0\\Default";
113 StartupInfo
.lpTitle
= NULL
;
114 StartupInfo
.dwFlags
= 0;
115 StartupInfo
.cbReserved2
= 0;
116 StartupInfo
.lpReserved2
= 0;
118 Result
= CreateProcessW(NULL
,
127 &ProcessInformation
);
130 TRACE("Failed to run setup process\n");
131 SwitchDesktop(WLSession
->WinlogonDesktop
);
135 /* Wait for process termination */
136 WaitForSingleObject(ProcessInformation
.hProcess
, INFINITE
);
138 GetExitCodeProcess(ProcessInformation
.hProcess
, &dwExitCode
);
141 CloseHandle(ProcessInformation
.hThread
);
142 CloseHandle(ProcessInformation
.hProcess
);
144 SwitchDesktop(WLSession
->WinlogonDesktop
);
146 TRACE ("RunSetup() done\n");
157 hThread
= CreateThread(NULL
,
164 CloseHandle(hThread
);
166 return hThread
!= NULL
;