- Get autochk, calc, cmd, devmgr, expand, format, gettype, hostname, lsass, msconfig...
[reactos.git] / reactos / subsys / system / setup / setup.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2003 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 /*
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS GUI/console setup
22 * FILE: subsys/system/setup/setup.c
23 * PURPOSE: Second stage setup
24 * PROGRAMMER: Eric Kohl
25 */
26 #define WIN32_NO_STATUS
27 #include <windows.h>
28 #include <tchar.h>
29 #include <syssetup/syssetup.h>
30 #include <userenv.h>
31 #include <tchar.h>
32
33 #define NDEBUG
34 #include <debug.h>
35
36
37 typedef DWORD (STDCALL *PINSTALL_REACTOS)(HINSTANCE hInstance);
38
39
40 /* FUNCTIONS ****************************************************************/
41
42 LPTSTR lstrchr(LPCTSTR s, TCHAR c)
43 {
44 while (*s)
45 {
46 if (*s == c)
47 return (LPTSTR)s;
48 s++;
49 }
50
51 if (c == (TCHAR)0)
52 return (LPTSTR)s;
53
54 return (LPTSTR)NULL;
55 }
56
57 static VOID
58 RunNewSetup (HINSTANCE hInstance)
59 {
60 HMODULE hDll;
61 PINSTALL_REACTOS InstallReactOS;
62
63 /* some dlls (loaded by syssetup) need a valid user profile */
64 InitializeProfiles();
65
66 hDll = LoadLibrary (TEXT("syssetup"));
67 if (hDll == NULL)
68 {
69 DPRINT("Failed to load 'syssetup'!\n");
70 return;
71 }
72
73 DPRINT("Loaded 'syssetup'!\n");
74 InstallReactOS = (PINSTALL_REACTOS)GetProcAddress (hDll, "InstallReactOS");
75
76 if (InstallReactOS == NULL)
77 {
78 DPRINT("Failed to get address for 'InstallReactOS()'!\n");
79 FreeLibrary (hDll);
80 return;
81 }
82
83 InstallReactOS (hInstance);
84
85 FreeLibrary (hDll);
86 }
87
88
89 int STDCALL
90 WinMain (HINSTANCE hInstance,
91 HINSTANCE hPrevInstance,
92 LPSTR lpCmdLine,
93 int nShowCmd)
94 {
95 LPTSTR CmdLine;
96 LPTSTR p;
97
98 CmdLine = GetCommandLine ();
99
100 DPRINT("CmdLine: <%s>\n",CmdLine);
101
102 p = lstrchr (CmdLine, TEXT('-'));
103 if (p == NULL)
104 return 0;
105
106 if (!lstrcmpi (p, TEXT("-newsetup")))
107 {
108 RunNewSetup (hInstance);
109 }
110
111 #if 0
112 /* Add new setup types here */
113 else if (...)
114 {
115
116 }
117 #endif
118
119 return 0;
120 }
121
122 /* EOF */