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 along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 TCHAR 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 TCHAR 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 TCHAR 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 _tcscpy(LogFont
.lfFaceName
, _T("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
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
198 SetWindowLongPtr(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
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
263 SetWindowLongPtr(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 SetWindowLongPtr(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
)
368 SetupData
.SelectedLangId
= SendMessage(hList
, CB_GETITEMDATA
, (WPARAM
) tindex
, (LPARAM
) 0);
369 LangID
= _tcstol(SetupData
.pLanguages
[SetupData
.SelectedLangId
].LangId
, NULL
, 16);
370 SetThreadLocale(MAKELCID(LangID
, SORT_DEFAULT
));
371 // FIXME: need to reload all resource to force
372 // the new language setting
375 hList
= GetDlgItem(hwndDlg
, IDC_KEYLAYOUT
);
376 tindex
= SendMessage(hList
,CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
377 if (tindex
!= CB_ERR
)
379 SetupData
.SelectedKBLayout
= SendMessage(hList
, CB_GETITEMDATA
, (WPARAM
) tindex
, (LPARAM
) 0);
397 static INT_PTR CALLBACK
398 TypeDlgProc(HWND hwndDlg
,
410 hwndControl
= GetParent(hwndDlg
);
412 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
413 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
415 CheckDlgButton(hwndDlg
, IDC_INSTALL
, BST_CHECKED
);
418 /*SendDlgItemMessage(hwndDlg,
428 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
433 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
436 case PSN_QUERYCANCEL
:
437 SetWindowLongPtr(hwndDlg
,
439 MessageBox(GetParent(hwndDlg
),
442 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
445 case PSN_WIZNEXT
: // set the selected data
446 SetupData
.RepairUpdateFlag
= !(SendMessage(GetDlgItem(hwndDlg
, IDC_INSTALL
),
449 (LPARAM
) 0) == BST_CHECKED
);
465 static INT_PTR CALLBACK
466 DeviceDlgProc(HWND hwndDlg
,
482 hwndControl
= GetParent(hwndDlg
);
484 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
485 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
488 /*SendDlgItemMessage(hwndDlg,
494 hList
= GetDlgItem(hwndDlg
, IDC_COMPUTER
);
496 for (i
=0; i
< SetupData
.CompCount
; i
++)
498 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) SetupData
.pComputers
[i
].Value
);
499 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
501 SendMessage(hList
, CB_SETCURSEL
, 0, 0); // set first as default
503 hList
= GetDlgItem(hwndDlg
, IDC_DISPLAY
);
505 for (i
=0; i
< SetupData
.DispCount
; i
++)
507 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) SetupData
.pDisplays
[i
].Value
);
508 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
510 SendMessage(hList
, CB_SETCURSEL
, 0, 0); // set first as default
512 hList
= GetDlgItem(hwndDlg
, IDC_KEYBOARD
);
514 for (i
=0; i
< SetupData
.KeybCount
; i
++)
516 tindex
= SendMessage(hList
,CB_ADDSTRING
,(WPARAM
)0,(LPARAM
)SetupData
.pKeyboards
[i
].Value
);
517 SendMessage(hList
,CB_SETITEMDATA
,tindex
,i
);
519 SendMessage(hList
,CB_SETCURSEL
,0,0); // set first as default
525 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
530 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
533 case PSN_QUERYCANCEL
:
534 SetWindowLongPtr(hwndDlg
,
536 MessageBox(GetParent(hwndDlg
),
539 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
542 case PSN_WIZNEXT
: // set the selected data
544 hList
= GetDlgItem(hwndDlg
, IDC_COMPUTER
);
546 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
547 if (tindex
!= CB_ERR
)
549 SetupData
.SelectedComputer
= SendMessage(hList
,
555 hList
= GetDlgItem(hwndDlg
, IDC_DISPLAY
);
557 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
558 if (tindex
!= CB_ERR
)
560 SetupData
.SelectedDisplay
= SendMessage(hList
,
566 hList
=GetDlgItem(hwndDlg
, IDC_KEYBOARD
);
568 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
569 if (tindex
!= CB_ERR
)
571 SetupData
.SelectedKeyboard
= SendMessage(hList
,
592 static INT_PTR CALLBACK
593 MoreOptDlgProc(HWND hwndDlg
,
602 CheckDlgButton(hwndDlg
, IDC_INSTFREELDR
, BST_CHECKED
);
603 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
606 (LPARAM
) SetupData
.InstallDir
);
612 switch(LOWORD(wParam
))
616 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
618 (WPARAM
) sizeof(SetupData
.InstallDir
) / sizeof(TCHAR
),
619 (LPARAM
) SetupData
.InstallDir
);
621 EndDialog(hwndDlg
, IDOK
);
627 EndDialog(hwndDlg
, IDCANCEL
);
637 static INT_PTR CALLBACK
638 PartitionDlgProc(HWND hwndDlg
,
649 switch(LOWORD(wParam
))
652 EndDialog(hwndDlg
, IDOK
);
655 EndDialog(hwndDlg
, IDCANCEL
);
663 static INT_PTR CALLBACK
664 DriveDlgProc(HWND hwndDlg
,
672 SP_DEVINFO_DATA DevInfoData
;
682 hwndControl
= GetParent(hwndDlg
);
684 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
685 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
688 /*SendDlgItemMessage(hwndDlg,
694 h
= SetupDiGetClassDevs(&GUID_DEVCLASS_DISKDRIVE
, NULL
, NULL
, DIGCF_PRESENT
);
695 if (h
!= INVALID_HANDLE_VALUE
)
697 hList
=GetDlgItem(hwndDlg
, IDC_PARTITION
);
698 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
699 for (i
=0; SetupDiEnumDeviceInfo(h
, i
, &DevInfoData
); i
++)
702 LPTSTR buffer
= NULL
;
703 DWORD buffersize
= 0;
705 while (!SetupDiGetDeviceRegistryProperty(h
,
713 if (GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
715 if (buffer
) LocalFree(buffer
);
716 buffer
= LocalAlloc(LPTR
, buffersize
* 2);
723 SendMessage(hList
, LB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) buffer
);
727 SetupDiDestroyDeviceInfoList(h
);
735 switch(LOWORD(wParam
))
737 case IDC_PARTMOREOPTS
:
739 MAKEINTRESOURCE(IDD_BOOTOPTIONS
),
741 (DLGPROC
) MoreOptDlgProc
);
745 MAKEINTRESOURCE(IDD_PARTITION
),
747 (DLGPROC
) PartitionDlgProc
);
757 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
762 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
765 case PSN_QUERYCANCEL
:
766 SetWindowLongPtr(hwndDlg
,
768 MessageBox(GetParent(hwndDlg
),
771 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
788 static INT_PTR CALLBACK
789 SummaryDlgProc(HWND hwndDlg
,
801 hwndControl
= GetParent(hwndDlg
);
803 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
804 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
806 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
807 ShowWindow(hwndControl
, SW_HIDE
);
808 EnableWindow(hwndControl
, FALSE
);
811 /*SendDlgItemMessage(hwndDlg,
821 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
826 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
842 static INT_PTR CALLBACK
843 ProcessDlgProc(HWND hwndDlg
,
855 hwndControl
= GetParent(hwndDlg
);
857 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
858 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
860 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
861 ShowWindow(hwndControl
, SW_HIDE
);
862 EnableWindow(hwndControl
, FALSE
);
865 /*SendDlgItemMessage(hwndDlg,
875 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
880 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
881 // disable all buttons during installation process
882 // PropSheet_SetWizButtons(GetParent(hwndDlg), 0 );
899 static INT_PTR CALLBACK
900 RestartDlgProc(HWND hwndDlg
,
912 hwndControl
= GetParent(hwndDlg
);
914 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
915 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
918 /*SendDlgItemMessage(hwndDlg,
931 hWndProgress
= GetDlgItem(hwndDlg
, IDC_RESTART_PROGRESS
);
932 Position
= SendMessage(hWndProgress
, PBM_GETPOS
, 0, 0);
935 KillTimer(hwndDlg
, 1);
936 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_FINISH
);
940 SendMessage(hWndProgress
, PBM_SETPOS
, Position
+ 1, 0);
950 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
954 case PSN_SETACTIVE
: // Only "Finish" for closing the App
956 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
957 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETRANGE
, 0, MAKELPARAM(0, 300));
958 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETPOS
, 0, 0);
959 SetTimer(hwndDlg
, 1, 50, NULL
);
979 WCHAR szPath
[MAX_PATH
];
983 INFCONTEXT InfContext
;
984 //TCHAR szValue[MAX_PATH];
988 GetModuleFileNameW(NULL
,szPath
,MAX_PATH
);
989 ch
= strrchrW(szPath
,L
'\\');
993 wcscat(szPath
, L
"\\txtsetup.sif");
994 hTxtsetupSif
= SetupOpenInfFileW(szPath
, NULL
, INF_STYLE_OLDNT
, NULL
);
995 if (hTxtsetupSif
!= INVALID_HANDLE_VALUE
)
998 Count
= SetupGetLineCount(hTxtsetupSif
, _T("Language"));
1001 SetupData
.pLanguages
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LANG
) * Count
);
1002 if (SetupData
.pLanguages
!= NULL
)
1004 SetupData
.LangCount
= Count
;
1006 if (SetupFindFirstLine(hTxtsetupSif
, _T("Language"), NULL
, &InfContext
))
1010 SetupGetStringField(&InfContext
,
1012 SetupData
.pLanguages
[Count
].LangId
,
1013 sizeof(SetupData
.pLanguages
[Count
].LangId
) / sizeof(TCHAR
),
1016 SetupGetStringField(&InfContext
,
1018 SetupData
.pLanguages
[Count
].LangName
,
1019 sizeof(SetupData
.pLanguages
[Count
].LangName
) / sizeof(TCHAR
),
1023 while (SetupFindNextLine(&InfContext
, &InfContext
) && Count
< SetupData
.LangCount
);
1028 // get keyboard layout list
1029 Count
= SetupGetLineCount(hTxtsetupSif
, _T("KeyboardLayout"));
1032 SetupData
.pKbLayouts
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(KBLAYOUT
) * Count
);
1033 if (SetupData
.pKbLayouts
!= NULL
)
1035 SetupData
.KbLayoutCount
= Count
;
1037 if (SetupFindFirstLine(hTxtsetupSif
, _T("KeyboardLayout"), NULL
, &InfContext
))
1041 SetupGetStringField(&InfContext
,
1043 SetupData
.pKbLayouts
[Count
].LayoutId
,
1044 sizeof(SetupData
.pKbLayouts
[Count
].LayoutId
) / sizeof(TCHAR
),
1047 SetupGetStringField(&InfContext
,
1049 SetupData
.pKbLayouts
[Count
].LayoutName
,
1050 sizeof(SetupData
.pKbLayouts
[Count
].LayoutName
) / sizeof(TCHAR
),
1054 while (SetupFindNextLine(&InfContext
, &InfContext
) && Count
< SetupData
.LangCount
);
1059 // get default for keyboard and language
1060 SetupData
.DefaultKBLayout
= -1;
1061 SetupData
.DefaultLang
= -1;
1063 // TODO: get defaults from underlaying running system
1064 if (SetupFindFirstLine(hTxtsetupSif
, _T("NLS"), _T("DefaultLayout"), &InfContext
))
1066 SetupGetStringField(&InfContext
, 1, tmp
, sizeof(tmp
) / sizeof(TCHAR
), &LineLength
);
1067 for (Count
= 0; Count
< SetupData
.KbLayoutCount
; Count
++)
1068 if (_tcscmp(tmp
, SetupData
.pKbLayouts
[Count
].LayoutId
) == 0)
1070 SetupData
.DefaultKBLayout
= Count
;
1075 if (SetupFindFirstLine(hTxtsetupSif
, _T("NLS"), _T("DefaultLanguage"), &InfContext
))
1077 SetupGetStringField(&InfContext
, 1, tmp
, sizeof(tmp
) / sizeof(TCHAR
), &LineLength
);
1078 for (Count
= 0; Count
< SetupData
.LangCount
; Count
++)
1079 if (_tcscmp(tmp
, SetupData
.pLanguages
[Count
].LangId
) == 0)
1081 SetupData
.DefaultLang
= Count
;
1086 // get computers list
1087 Count
= SetupGetLineCount(hTxtsetupSif
, _T("Computer"));
1090 SetupData
.pComputers
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(GENENTRY
) * Count
);
1091 if (SetupData
.pComputers
!= NULL
)
1093 SetupData
.CompCount
= Count
;
1095 if (SetupFindFirstLine(hTxtsetupSif
, _T("Computer"), NULL
, &InfContext
))
1099 SetupGetStringField(&InfContext
,
1101 SetupData
.pComputers
[Count
].Id
,
1102 sizeof(SetupData
.pComputers
[Count
].Id
) / sizeof(TCHAR
),
1105 SetupGetStringField(&InfContext
,
1107 SetupData
.pComputers
[Count
].Value
,
1108 sizeof(SetupData
.pComputers
[Count
].Value
) / sizeof(TCHAR
),
1112 while (SetupFindNextLine(&InfContext
, &InfContext
) && Count
< SetupData
.CompCount
);
1118 Count
= SetupGetLineCount(hTxtsetupSif
, _T("Display"));
1121 SetupData
.pDisplays
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(GENENTRY
) * Count
);
1122 if (SetupData
.pDisplays
!= NULL
)
1124 SetupData
.DispCount
= Count
;
1127 if (SetupFindFirstLine(hTxtsetupSif
, _T("Display"), NULL
, &InfContext
))
1131 SetupGetStringField(&InfContext
,
1133 SetupData
.pDisplays
[Count
].Id
,
1134 sizeof(SetupData
.pDisplays
[Count
].Id
) / sizeof(TCHAR
),
1137 SetupGetStringField(&InfContext
,
1139 SetupData
.pDisplays
[Count
].Value
,
1140 sizeof(SetupData
.pDisplays
[Count
].Value
) / sizeof(TCHAR
),
1144 while (SetupFindNextLine(&InfContext
, &InfContext
) && Count
< SetupData
.DispCount
);
1149 // get keyboard list
1150 Count
= SetupGetLineCount(hTxtsetupSif
, _T("Keyboard"));
1153 SetupData
.pKeyboards
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(GENENTRY
) * Count
);
1154 if (SetupData
.pKeyboards
!= NULL
)
1156 SetupData
.KeybCount
= Count
;
1159 if (SetupFindFirstLine(hTxtsetupSif
, _T("Keyboard"), NULL
, &InfContext
))
1163 SetupGetStringField(&InfContext
,
1165 SetupData
.pKeyboards
[Count
].Id
,
1166 sizeof(SetupData
.pKeyboards
[Count
].Id
) / sizeof(TCHAR
),
1169 SetupGetStringField(&InfContext
,
1171 SetupData
.pKeyboards
[Count
].Value
,
1172 sizeof(SetupData
.pKeyboards
[Count
].Value
) / sizeof(TCHAR
),
1176 while (SetupFindNextLine(&InfContext
, &InfContext
) && Count
< SetupData
.KeybCount
);
1181 // get install directory
1182 if (SetupFindFirstLine(hTxtsetupSif
, _T("SetupData"), _T("DefaultPath"), &InfContext
))
1184 SetupGetStringField(&InfContext
,
1186 SetupData
.InstallDir
,
1187 sizeof(SetupData
.InstallDir
) / sizeof(TCHAR
),
1190 SetupCloseInfFile(hTxtsetupSif
);
1194 BOOL
isUnattendSetup()
1196 WCHAR szPath
[MAX_PATH
];
1198 HINF hUnattendedInf
;
1199 INFCONTEXT InfContext
;
1200 TCHAR szValue
[MAX_PATH
];
1205 GetModuleFileNameW(NULL
, szPath
, MAX_PATH
);
1206 ch
= strrchrW(szPath
, L
'\\');
1210 wcscat(szPath
, L
"\\unattend.inf");
1211 hUnattendedInf
= SetupOpenInfFileW(szPath
, NULL
, INF_STYLE_OLDNT
, NULL
);
1213 if (hUnattendedInf
!= INVALID_HANDLE_VALUE
)
1215 if (SetupFindFirstLine(hUnattendedInf
, _T("Unattend"), _T("UnattendSetupEnabled"),&InfContext
))
1217 if (SetupGetStringField(&InfContext
,
1220 sizeof(szValue
) / sizeof(TCHAR
),
1221 &LineLength
) && (_tcsicmp(szValue
, _T("yes")) == 0))
1223 result
= 1; // unattendSetup enabled
1224 // read values and store in SetupData
1227 SetupCloseInfFile(hUnattendedInf
);
1234 _tWinMain(HINSTANCE hInst
,
1235 HINSTANCE hPrevInstance
,
1239 PROPSHEETHEADER psh
;
1240 HPROPSHEETPAGE ahpsp
[8];
1241 PROPSHEETPAGE psp
= {0};
1244 isUnattend
= isUnattendSetup();
1248 LoadString(hInst
,IDS_ABORTSETUP
, abort_msg
, sizeof(abort_msg
)/sizeof(TCHAR
));
1249 LoadString(hInst
,IDS_ABORTSETUP2
, abort_title
,sizeof(abort_title
)/sizeof(TCHAR
));
1253 /* Create the Start page, until setup is working */
1254 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1255 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
1256 psp
.hInstance
= hInst
;
1258 psp
.pfnDlgProc
= StartDlgProc
;
1259 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_STARTPAGE
);
1260 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1262 /* Create language selection page */
1263 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1264 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1265 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_LANGTITLE
);
1266 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_LANGSUBTITLE
);
1267 psp
.hInstance
= hInst
;
1269 psp
.pfnDlgProc
= LangSelDlgProc
;
1270 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_LANGSELPAGE
);
1271 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1273 /* Create install type selection page */
1274 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1275 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1276 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_TYPETITLE
);
1277 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_TYPESUBTITLE
);
1278 psp
.hInstance
= hInst
;
1280 psp
.pfnDlgProc
= TypeDlgProc
;
1281 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_TYPEPAGE
);
1282 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1284 /* Create device settings page */
1285 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1286 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1287 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_DEVICETITLE
);
1288 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_DEVICESUBTITLE
);
1289 psp
.hInstance
= hInst
;
1291 psp
.pfnDlgProc
= DeviceDlgProc
;
1292 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DEVICEPAGE
);
1293 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1295 /* Create install device settings page / boot method / install directory */
1296 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1297 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1298 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_DRIVETITLE
);
1299 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_DRIVESUBTITLE
);
1300 psp
.hInstance
= hInst
;
1302 psp
.pfnDlgProc
= DriveDlgProc
;
1303 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DRIVEPAGE
);
1304 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1306 /* Create summary page */
1307 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1308 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1309 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_SUMMARYTITLE
);
1310 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_SUMMARYSUBTITLE
);
1311 psp
.hInstance
= hInst
;
1313 psp
.pfnDlgProc
= SummaryDlgProc
;
1314 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_SUMMARYPAGE
);
1315 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1318 /* Create installation progress page */
1319 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1320 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1321 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_PROCESSTITLE
);
1322 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_PROCESSSUBTITLE
);
1323 psp
.hInstance
= hInst
;
1325 psp
.pfnDlgProc
= ProcessDlgProc
;
1326 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_PROCESSPAGE
);
1327 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1331 /* Create finish to reboot page */
1332 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1333 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1334 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_RESTARTTITLE
);
1335 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_RESTARTSUBTITLE
);
1336 psp
.hInstance
= hInst
;
1338 psp
.pfnDlgProc
= RestartDlgProc
;
1339 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_RESTARTPAGE
);
1340 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1343 /* Create the property sheet */
1344 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
1345 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
;
1346 psh
.hInstance
= hInst
;
1347 psh
.hwndParent
= NULL
;
1348 psh
.nPages
= nPages
;
1351 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
1352 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
1354 /* Create title font */
1355 hTitleFont
= CreateTitleFont();
1357 /* Display the wizard */
1358 PropertySheet(&psh
);
1360 DeleteObject(hTitleFont
);