3 * Copyright (C) 2004-2008 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.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS GUI first stage setup application
23 * FILE: subsys/system/reactos/reactos.c
24 * PROGRAMMERS: Eric Kohl
26 * Dmitry Chapyshev (dmitry@reactos.org)
35 #include <wine/unicode.h>
39 /* GLOBALS ******************************************************************/
49 typedef struct _KBLAYOUT
52 WCHAR LayoutName
[128];
54 } KBLAYOUT
, *PKBLAYOUT
;
57 // generic entries with simple 1:1 mapping
58 typedef struct _GENENTRY
62 } GENENTRY
, *PGENENTRY
;
67 LONG DestDiskNumber
; // physical disk
68 LONG DestPartNumber
; // partition on disk
69 LONG DestPartSize
; // if partition doesn't exist, size of partition
70 LONG FSType
; // file system type on partition
71 LONG MBRInstallType
; // install bootloader
72 LONG FormatPart
; // type of format the partition
73 LONG SelectedLangId
; // selected language (table index)
74 LONG SelectedKBLayout
; // selected keyboard layout (table index)
75 WCHAR InstallDir
[MAX_PATH
]; // installation directory on hdd
76 LONG SelectedComputer
; // selected computer type (table index)
77 LONG SelectedDisplay
; // selected display type (table index)
78 LONG SelectedKeyboard
; // selected keyboard type (table index)
79 BOOLEAN RepairUpdateFlag
; // flag for update/repair an installed reactos
81 LONG DefaultLang
; // default language (table index)
84 LONG DefaultKBLayout
; // default keyboard layout (table index)
95 typedef struct _IMGINFO
100 } IMGINFO
, *PIMGINFO
;
102 WCHAR abort_msg
[512], abort_title
[64];
106 /* FUNCTIONS ****************************************************************/
109 CenterWindow(HWND hWnd
)
115 hWndParent
= GetParent(hWnd
);
116 if (hWndParent
== NULL
)
117 hWndParent
= GetDesktopWindow();
119 GetWindowRect(hWndParent
, &rcParent
);
120 GetWindowRect(hWnd
, &rcWindow
);
124 ((rcParent
.right
- rcParent
.left
) - (rcWindow
.right
- rcWindow
.left
)) / 2,
125 ((rcParent
.bottom
- rcParent
.top
) - (rcWindow
.bottom
- rcWindow
.top
)) / 2,
132 CreateTitleFont(VOID
)
134 NONCLIENTMETRICS ncm
;
140 ncm
.cbSize
= sizeof(NONCLIENTMETRICS
);
141 SystemParametersInfo(SPI_GETNONCLIENTMETRICS
, 0, &ncm
, 0);
143 LogFont
= ncm
.lfMessageFont
;
144 LogFont
.lfWeight
= FW_BOLD
;
145 wcscpy(LogFont
.lfFaceName
, L
"MS Shell Dlg");
149 LogFont
.lfHeight
= 0 - GetDeviceCaps (hdc
, LOGPIXELSY
) * FontSize
/ 72;
150 hFont
= CreateFontIndirect(&LogFont
);
151 ReleaseDC(NULL
, hdc
);
157 InitImageInfo(PIMGINFO ImgInfo
)
161 ZeroMemory(ImgInfo
, sizeof(*ImgInfo
));
163 ImgInfo
->hBitmap
= LoadImage(hInstance
,
164 MAKEINTRESOURCE(IDB_ROSLOGO
),
170 if (ImgInfo
->hBitmap
!= NULL
)
172 GetObject(ImgInfo
->hBitmap
, sizeof(BITMAP
), &bitmap
);
174 ImgInfo
->cxSource
= bitmap
.bmWidth
;
175 ImgInfo
->cySource
= bitmap
.bmHeight
;
179 static INT_PTR CALLBACK
180 StartDlgProc(HWND hwndDlg
,
192 hwndControl
= GetParent(hwndDlg
);
194 /* Center the wizard window */
195 CenterWindow (hwndControl
);
197 dwStyle
= GetWindowLong(hwndControl
, GWL_STYLE
);
198 SetWindowLong(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
200 /* Hide and disable the 'Cancel' button at the moment,
201 * we use this button to cancel the setup process
204 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
205 ShowWindow (hwndControl
, SW_HIDE
);
206 EnableWindow (hwndControl
, FALSE
);
209 SendDlgItemMessage(hwndDlg
,
219 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
224 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
240 static INT_PTR CALLBACK
241 LangSelDlgProc(HWND hwndDlg
,
251 pImgInfo
= (PIMGINFO
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
260 hwndControl
= GetParent(hwndDlg
);
262 dwStyle
= GetWindowLong(hwndControl
, GWL_STYLE
);
263 SetWindowLong(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
265 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
266 ShowWindow (hwndControl
, SW_SHOW
);
267 EnableWindow (hwndControl
, TRUE
);
269 pImgInfo
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IMGINFO
));
270 if (pImgInfo
== NULL
)
272 EndDialog(hwndDlg
, 0);
276 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pImgInfo
);
278 InitImageInfo(pImgInfo
);
281 /*SendDlgItemMessage(hwndDlg,
287 hList
= GetDlgItem(hwndDlg
, IDC_LANGUAGES
);
289 for (i
=0; i
< SetupData
.LangCount
; i
++)
291 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) SetupData
.pLanguages
[i
].LangName
);
292 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
293 if (SetupData
.DefaultLang
== i
)
294 SendMessage(hList
, CB_SETCURSEL
, (WPARAM
) tindex
,(LPARAM
) 0);
297 hList
= GetDlgItem(hwndDlg
, IDC_KEYLAYOUT
);
299 for (i
=0; i
< SetupData
.KbLayoutCount
; i
++)
301 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
)SetupData
.pKbLayouts
[i
].LayoutName
);
302 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
303 if (SetupData
.DefaultKBLayout
== i
)
304 SendMessage(hList
,CB_SETCURSEL
,(WPARAM
)tindex
,(LPARAM
)0);
311 LPDRAWITEMSTRUCT lpDrawItem
;
312 lpDrawItem
= (LPDRAWITEMSTRUCT
) lParam
;
314 if (lpDrawItem
->CtlID
== IDB_ROSLOGO
)
319 /* position image in centre of dialog */
320 left
= (lpDrawItem
->rcItem
.right
- pImgInfo
->cxSource
) / 2;
322 hdcMem
= CreateCompatibleDC(lpDrawItem
->hDC
);
325 SelectObject(hdcMem
, pImgInfo
->hBitmap
);
326 BitBlt(lpDrawItem
->hDC
,
328 lpDrawItem
->rcItem
.top
,
329 lpDrawItem
->rcItem
.right
- lpDrawItem
->rcItem
.left
,
330 lpDrawItem
->rcItem
.bottom
- lpDrawItem
->rcItem
.top
,
343 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
348 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
351 case PSN_QUERYCANCEL
:
352 SetWindowLong(hwndDlg
,
354 MessageBox(GetParent(hwndDlg
),
357 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
360 case PSN_WIZNEXT
: // set the selected data
362 hList
= GetDlgItem(hwndDlg
, IDC_LANGUAGES
);
363 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
365 if (tindex
!= CB_ERR
)
367 SetupData
.SelectedLangId
= SendMessage(hList
, CB_GETITEMDATA
, (WPARAM
) tindex
, (LPARAM
) 0);
368 WORD LangID
= wcstol(SetupData
.pLanguages
[SetupData
.SelectedLangId
].LangId
, NULL
, 16);
369 SetThreadLocale(MAKELCID(LangID
, SORT_DEFAULT
));
370 // FIXME: need to reload all resource to force
371 // the new language setting
374 hList
= GetDlgItem(hwndDlg
, IDC_KEYLAYOUT
);
375 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
376 if (tindex
!= CB_ERR
)
378 SetupData
.SelectedKBLayout
= SendMessage(hList
, CB_GETITEMDATA
, (WPARAM
) tindex
, (LPARAM
) 0);
396 static INT_PTR CALLBACK
397 TypeDlgProc(HWND hwndDlg
,
409 hwndControl
= GetParent(hwndDlg
);
411 dwStyle
= GetWindowLong(hwndControl
, GWL_STYLE
);
412 SetWindowLong(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
414 CheckDlgButton(hwndDlg
, IDC_INSTALL
, BST_CHECKED
);
417 /*SendDlgItemMessage(hwndDlg,
427 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
432 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
435 case PSN_QUERYCANCEL
:
436 SetWindowLong(hwndDlg
,
438 MessageBox(GetParent(hwndDlg
),
441 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
444 case PSN_WIZNEXT
: // set the selected data
445 SetupData
.RepairUpdateFlag
= !(SendMessage(GetDlgItem(hwndDlg
, IDC_INSTALL
),
448 (LPARAM
) 0) == BST_CHECKED
);
464 static INT_PTR CALLBACK
465 DeviceDlgProc(HWND hwndDlg
,
481 hwndControl
= GetParent(hwndDlg
);
483 dwStyle
= GetWindowLong(hwndControl
, GWL_STYLE
);
484 SetWindowLong(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
487 /*SendDlgItemMessage(hwndDlg,
493 hList
= GetDlgItem(hwndDlg
, IDC_COMPUTER
);
495 for (i
=0; i
< SetupData
.CompCount
; i
++)
497 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) SetupData
.pComputers
[i
].Value
);
498 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
500 SendMessage(hList
, CB_SETCURSEL
, 0, 0); // set first as default
502 hList
= GetDlgItem(hwndDlg
, IDC_DISPLAY
);
504 for (i
=0; i
< SetupData
.DispCount
; i
++)
506 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) SetupData
.pDisplays
[i
].Value
);
507 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
509 SendMessage(hList
, CB_SETCURSEL
, 0, 0); // set first as default
511 hList
= GetDlgItem(hwndDlg
, IDC_KEYBOARD
);
513 for (i
=0; i
< SetupData
.KeybCount
; i
++)
515 tindex
= SendMessage(hList
,CB_ADDSTRING
,(WPARAM
)0,(LPARAM
)SetupData
.pKeyboards
[i
].Value
);
516 SendMessage(hList
,CB_SETITEMDATA
,tindex
,i
);
518 SendMessage(hList
,CB_SETCURSEL
,0,0); // set first as default
524 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
529 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
532 case PSN_QUERYCANCEL
:
533 SetWindowLong(hwndDlg
,
535 MessageBox(GetParent(hwndDlg
),
538 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
541 case PSN_WIZNEXT
: // set the selected data
543 hList
= GetDlgItem(hwndDlg
, IDC_COMPUTER
);
545 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
546 if (tindex
!= CB_ERR
)
548 SetupData
.SelectedComputer
= SendMessage(hList
,
554 hList
= GetDlgItem(hwndDlg
, IDC_DISPLAY
);
556 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
557 if (tindex
!= CB_ERR
)
559 SetupData
.SelectedDisplay
= SendMessage(hList
,
565 hList
=GetDlgItem(hwndDlg
, IDC_KEYBOARD
);
567 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
568 if (tindex
!= CB_ERR
)
570 SetupData
.SelectedKeyboard
= SendMessage(hList
,
591 static INT_PTR CALLBACK
592 MoreOptDlgProc(HWND hwndDlg
,
601 CheckDlgButton(hwndDlg
, IDC_INSTFREELDR
, BST_CHECKED
);
602 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
605 (LPARAM
) SetupData
.InstallDir
);
611 switch(LOWORD(wParam
))
615 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
617 (WPARAM
) sizeof(SetupData
.InstallDir
) / sizeof(WCHAR
),
618 (LPARAM
) SetupData
.InstallDir
);
620 EndDialog(hwndDlg
, IDOK
);
626 EndDialog(hwndDlg
, IDCANCEL
);
636 static INT_PTR CALLBACK
637 PartitionDlgProc(HWND hwndDlg
,
648 switch(LOWORD(wParam
))
651 EndDialog(hwndDlg
, IDOK
);
654 EndDialog(hwndDlg
, IDCANCEL
);
662 static INT_PTR CALLBACK
663 DriveDlgProc(HWND hwndDlg
,
671 SP_DEVINFO_DATA DevInfoData
;
681 hwndControl
= GetParent(hwndDlg
);
683 dwStyle
= GetWindowLong(hwndControl
, GWL_STYLE
);
684 SetWindowLong(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
687 /*SendDlgItemMessage(hwndDlg,
693 h
= SetupDiGetClassDevs(&GUID_DEVCLASS_DISKDRIVE
, NULL
, NULL
, DIGCF_PRESENT
);
694 if (h
!= INVALID_HANDLE_VALUE
)
696 hList
=GetDlgItem(hwndDlg
, IDC_PARTITION
);
697 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
698 for (i
=0; SetupDiEnumDeviceInfo(h
, i
, &DevInfoData
); i
++)
701 LPTSTR buffer
= NULL
;
702 DWORD buffersize
= 0;
704 while (!SetupDiGetDeviceRegistryProperty(h
,
712 if (GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
714 if (buffer
) LocalFree(buffer
);
715 buffer
= LocalAlloc(LPTR
, buffersize
* 2);
722 SendMessage(hList
, LB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) buffer
);
726 SetupDiDestroyDeviceInfoList(h
);
734 switch(LOWORD(wParam
))
736 case IDC_PARTMOREOPTS
:
738 MAKEINTRESOURCE(IDD_BOOTOPTIONS
),
740 (DLGPROC
) MoreOptDlgProc
);
744 MAKEINTRESOURCE(IDD_PARTITION
),
746 (DLGPROC
) PartitionDlgProc
);
756 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
761 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
764 case PSN_QUERYCANCEL
:
765 SetWindowLong(hwndDlg
,
767 MessageBox(GetParent(hwndDlg
),
770 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
787 static INT_PTR CALLBACK
788 SummaryDlgProc(HWND hwndDlg
,
800 hwndControl
= GetParent(hwndDlg
);
802 dwStyle
= GetWindowLong(hwndControl
, GWL_STYLE
);
803 SetWindowLong(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
805 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
806 ShowWindow(hwndControl
, SW_HIDE
);
807 EnableWindow(hwndControl
, FALSE
);
810 /*SendDlgItemMessage(hwndDlg,
820 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
825 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
841 static INT_PTR CALLBACK
842 ProcessDlgProc(HWND hwndDlg
,
854 hwndControl
= GetParent(hwndDlg
);
856 dwStyle
= GetWindowLong(hwndControl
, GWL_STYLE
);
857 SetWindowLong(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
859 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
860 ShowWindow(hwndControl
, SW_HIDE
);
861 EnableWindow(hwndControl
, FALSE
);
864 /*SendDlgItemMessage(hwndDlg,
874 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
879 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
880 // disable all buttons during installation process
881 // PropSheet_SetWizButtons(GetParent(hwndDlg), 0 );
898 static INT_PTR CALLBACK
899 RestartDlgProc(HWND hwndDlg
,
911 hwndControl
= GetParent(hwndDlg
);
913 dwStyle
= GetWindowLong(hwndControl
, GWL_STYLE
);
914 SetWindowLong(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
917 /*SendDlgItemMessage(hwndDlg,
930 hWndProgress
= GetDlgItem(hwndDlg
, IDC_RESTART_PROGRESS
);
931 Position
= SendMessage(hWndProgress
, PBM_GETPOS
, 0, 0);
934 KillTimer(hwndDlg
, 1);
935 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_FINISH
);
939 SendMessage(hWndProgress
, PBM_SETPOS
, Position
+ 1, 0);
949 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
953 case PSN_SETACTIVE
: // Only "Finish" for closing the App
955 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
956 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETRANGE
, 0, MAKELPARAM(0, 300));
957 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETPOS
, 0, 0);
958 SetTimer(hwndDlg
, 1, 50, NULL
);
978 WCHAR szPath
[MAX_PATH
];
982 INFCONTEXT InfContext
;
983 //WCHAR szValue[MAX_PATH];
987 GetModuleFileNameW(NULL
,szPath
,MAX_PATH
);
988 ch
= strrchrW(szPath
,L
'\\');
992 wcscat(szPath
, L
"\\txtsetup.sif");
993 hTxtsetupSif
= SetupOpenInfFileW(szPath
, NULL
, INF_STYLE_OLDNT
, NULL
);
994 if (hTxtsetupSif
!= INVALID_HANDLE_VALUE
)
997 Count
= SetupGetLineCount(hTxtsetupSif
, L
"Language");
1000 SetupData
.pLanguages
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LANG
) * Count
);
1001 if (SetupData
.pLanguages
!= NULL
)
1003 SetupData
.LangCount
= Count
;
1005 if (SetupFindFirstLine(hTxtsetupSif
, L
"Language", NULL
, &InfContext
))
1009 SetupGetStringField(&InfContext
,
1011 SetupData
.pLanguages
[Count
].LangId
,
1012 sizeof(SetupData
.pLanguages
[Count
].LangId
) / sizeof(WCHAR
),
1015 SetupGetStringField(&InfContext
,
1017 SetupData
.pLanguages
[Count
].LangName
,
1018 sizeof(SetupData
.pLanguages
[Count
].LangName
) / sizeof(WCHAR
),
1022 while (SetupFindNextLine(&InfContext
, &InfContext
) && Count
< SetupData
.LangCount
);
1027 // get keyboard layout list
1028 Count
= SetupGetLineCount(hTxtsetupSif
, L
"KeyboardLayout");
1031 SetupData
.pKbLayouts
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(KBLAYOUT
) * Count
);
1032 if (SetupData
.pKbLayouts
!= NULL
)
1034 SetupData
.KbLayoutCount
= Count
;
1036 if (SetupFindFirstLine(hTxtsetupSif
, L
"KeyboardLayout", NULL
, &InfContext
))
1040 SetupGetStringField(&InfContext
,
1042 SetupData
.pKbLayouts
[Count
].LayoutId
,
1043 sizeof(SetupData
.pKbLayouts
[Count
].LayoutId
) / sizeof(WCHAR
),
1046 SetupGetStringField(&InfContext
,
1048 SetupData
.pKbLayouts
[Count
].LayoutName
,
1049 sizeof(SetupData
.pKbLayouts
[Count
].LayoutName
) / sizeof(WCHAR
),
1053 while (SetupFindNextLine(&InfContext
, &InfContext
) && Count
< SetupData
.LangCount
);
1058 // get default for keyboard and language
1059 SetupData
.DefaultKBLayout
= -1;
1060 SetupData
.DefaultLang
= -1;
1062 // TODO: get defaults from underlaying running system
1063 if (SetupFindFirstLine(hTxtsetupSif
, L
"NLS", L
"DefaultLayout", &InfContext
))
1065 SetupGetStringField(&InfContext
, 1, tmp
, sizeof(tmp
) / sizeof(WCHAR
), &LineLength
);
1066 for (Count
= 0; Count
< SetupData
.KbLayoutCount
; Count
++)
1067 if (wcscmp(tmp
, SetupData
.pKbLayouts
[Count
].LayoutId
) == 0)
1069 SetupData
.DefaultKBLayout
= Count
;
1074 if (SetupFindFirstLine(hTxtsetupSif
, L
"NLS", L
"DefaultLanguage", &InfContext
))
1076 SetupGetStringField(&InfContext
, 1, tmp
, sizeof(tmp
) / sizeof(WCHAR
), &LineLength
);
1077 for (Count
= 0; Count
< SetupData
.LangCount
; Count
++)
1078 if (wcscmp(tmp
, SetupData
.pLanguages
[Count
].LangId
) == 0)
1080 SetupData
.DefaultLang
= Count
;
1085 // get computers list
1086 Count
= SetupGetLineCount(hTxtsetupSif
, L
"Computer");
1089 SetupData
.pComputers
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(GENENTRY
) * Count
);
1090 if (SetupData
.pComputers
!= NULL
)
1092 SetupData
.CompCount
= Count
;
1094 if (SetupFindFirstLine(hTxtsetupSif
, L
"Computer", NULL
, &InfContext
))
1098 SetupGetStringField(&InfContext
,
1100 SetupData
.pComputers
[Count
].Id
,
1101 sizeof(SetupData
.pComputers
[Count
].Id
) / sizeof(WCHAR
),
1104 SetupGetStringField(&InfContext
,
1106 SetupData
.pComputers
[Count
].Value
,
1107 sizeof(SetupData
.pComputers
[Count
].Value
) / sizeof(WCHAR
),
1111 while (SetupFindNextLine(&InfContext
, &InfContext
) && Count
< SetupData
.CompCount
);
1117 Count
= SetupGetLineCount(hTxtsetupSif
, L
"Display");
1120 SetupData
.pDisplays
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(GENENTRY
) * Count
);
1121 if (SetupData
.pDisplays
!= NULL
)
1123 SetupData
.DispCount
= Count
;
1126 if (SetupFindFirstLine(hTxtsetupSif
, L
"Display", NULL
, &InfContext
))
1130 SetupGetStringField(&InfContext
,
1132 SetupData
.pDisplays
[Count
].Id
,
1133 sizeof(SetupData
.pDisplays
[Count
].Id
) / sizeof(WCHAR
),
1136 SetupGetStringField(&InfContext
,
1138 SetupData
.pDisplays
[Count
].Value
,
1139 sizeof(SetupData
.pDisplays
[Count
].Value
) / sizeof(WCHAR
),
1143 while (SetupFindNextLine(&InfContext
, &InfContext
) && Count
< SetupData
.DispCount
);
1148 // get keyboard list
1149 Count
= SetupGetLineCount(hTxtsetupSif
, L
"Keyboard");
1152 SetupData
.pKeyboards
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(GENENTRY
) * Count
);
1153 if (SetupData
.pKeyboards
!= NULL
)
1155 SetupData
.KeybCount
= Count
;
1158 if (SetupFindFirstLine(hTxtsetupSif
, L
"Keyboard", NULL
, &InfContext
))
1162 SetupGetStringField(&InfContext
,
1164 SetupData
.pKeyboards
[Count
].Id
,
1165 sizeof(SetupData
.pKeyboards
[Count
].Id
) / sizeof(WCHAR
),
1168 SetupGetStringField(&InfContext
,
1170 SetupData
.pKeyboards
[Count
].Value
,
1171 sizeof(SetupData
.pKeyboards
[Count
].Value
) / sizeof(WCHAR
),
1175 while (SetupFindNextLine(&InfContext
, &InfContext
) && Count
< SetupData
.KeybCount
);
1180 // get install directory
1181 if (SetupFindFirstLine(hTxtsetupSif
, L
"SetupData", L
"DefaultPath", &InfContext
))
1183 SetupGetStringField(&InfContext
,
1185 SetupData
.InstallDir
,
1186 sizeof(SetupData
.InstallDir
) / sizeof(WCHAR
),
1189 SetupCloseInfFile(hTxtsetupSif
);
1193 BOOL
isUnattendSetup()
1195 WCHAR szPath
[MAX_PATH
];
1197 HINF hUnattendedInf
;
1198 INFCONTEXT InfContext
;
1199 WCHAR szValue
[MAX_PATH
];
1204 GetModuleFileNameW(NULL
, szPath
, MAX_PATH
);
1205 ch
= strrchrW(szPath
, L
'\\');
1209 wcscat(szPath
, L
"\\unattend.inf");
1210 hUnattendedInf
= SetupOpenInfFileW(szPath
, NULL
, INF_STYLE_OLDNT
, NULL
);
1212 if (hUnattendedInf
!= INVALID_HANDLE_VALUE
)
1214 if (SetupFindFirstLine(hUnattendedInf
, L
"Unattend", L
"UnattendSetupEnabled",&InfContext
))
1216 if (SetupGetStringField(&InfContext
,
1219 sizeof(szValue
) / sizeof(WCHAR
),
1220 &LineLength
) && (_wcsicmp(szValue
, L
"yes") == 0))
1222 result
= 1; // unattendSetup enabled
1223 // read values and store in SetupData
1226 SetupCloseInfFile(hUnattendedInf
);
1233 wWinMain(HINSTANCE hInst
,
1234 HINSTANCE hPrevInstance
,
1238 PROPSHEETHEADER psh
;
1239 HPROPSHEETPAGE ahpsp
[8];
1240 PROPSHEETPAGE psp
= {0};
1243 isUnattend
= isUnattendSetup();
1247 LoadString(hInst
, IDS_ABORTSETUP
, abort_msg
, sizeof(abort_msg
) / sizeof(WCHAR
));
1248 LoadString(hInst
, IDS_ABORTSETUP2
, abort_title
, sizeof(abort_title
) / sizeof(WCHAR
));
1252 /* Create the Start page, until setup is working */
1253 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1254 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
1255 psp
.hInstance
= hInst
;
1257 psp
.pfnDlgProc
= StartDlgProc
;
1258 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_STARTPAGE
);
1259 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1261 /* Create language selection page */
1262 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1263 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1264 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_LANGTITLE
);
1265 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_LANGSUBTITLE
);
1266 psp
.hInstance
= hInst
;
1268 psp
.pfnDlgProc
= LangSelDlgProc
;
1269 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_LANGSELPAGE
);
1270 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1272 /* Create install type selection page */
1273 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1274 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1275 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_TYPETITLE
);
1276 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_TYPESUBTITLE
);
1277 psp
.hInstance
= hInst
;
1279 psp
.pfnDlgProc
= TypeDlgProc
;
1280 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_TYPEPAGE
);
1281 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1283 /* Create device settings page */
1284 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1285 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1286 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_DEVICETITLE
);
1287 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_DEVICESUBTITLE
);
1288 psp
.hInstance
= hInst
;
1290 psp
.pfnDlgProc
= DeviceDlgProc
;
1291 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DEVICEPAGE
);
1292 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1294 /* Create install device settings page / boot method / install directory */
1295 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1296 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1297 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_DRIVETITLE
);
1298 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_DRIVESUBTITLE
);
1299 psp
.hInstance
= hInst
;
1301 psp
.pfnDlgProc
= DriveDlgProc
;
1302 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DRIVEPAGE
);
1303 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1305 /* Create summary page */
1306 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1307 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1308 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_SUMMARYTITLE
);
1309 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_SUMMARYSUBTITLE
);
1310 psp
.hInstance
= hInst
;
1312 psp
.pfnDlgProc
= SummaryDlgProc
;
1313 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_SUMMARYPAGE
);
1314 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1317 /* Create installation progress page */
1318 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1319 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1320 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_PROCESSTITLE
);
1321 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_PROCESSSUBTITLE
);
1322 psp
.hInstance
= hInst
;
1324 psp
.pfnDlgProc
= ProcessDlgProc
;
1325 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_PROCESSPAGE
);
1326 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1330 /* Create finish to reboot page */
1331 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1332 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1333 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_RESTARTTITLE
);
1334 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_RESTARTSUBTITLE
);
1335 psp
.hInstance
= hInst
;
1337 psp
.pfnDlgProc
= RestartDlgProc
;
1338 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_RESTARTPAGE
);
1339 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1342 /* Create the property sheet */
1343 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
1344 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
;
1345 psh
.hInstance
= hInst
;
1346 psh
.hwndParent
= NULL
;
1347 psh
.nPages
= nPages
;
1350 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
1351 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
1353 /* Create title font */
1354 hTitleFont
= CreateTitleFont();
1356 /* Display the wizard */
1357 PropertySheet(&psh
);
1359 DeleteObject(hTitleFont
);