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 LONG
LoadGenentry(HINF hinf
,PCTSTR name
,PGENENTRY gen
,PINFCONTEXT context
);
108 /* FUNCTIONS ****************************************************************/
111 CenterWindow(HWND hWnd
)
117 hWndParent
= GetParent(hWnd
);
118 if (hWndParent
== NULL
)
119 hWndParent
= GetDesktopWindow();
121 GetWindowRect(hWndParent
, &rcParent
);
122 GetWindowRect(hWnd
, &rcWindow
);
126 ((rcParent
.right
- rcParent
.left
) - (rcWindow
.right
- rcWindow
.left
)) / 2,
127 ((rcParent
.bottom
- rcParent
.top
) - (rcWindow
.bottom
- rcWindow
.top
)) / 2,
134 CreateTitleFont(VOID
)
136 NONCLIENTMETRICS ncm
;
142 ncm
.cbSize
= sizeof(NONCLIENTMETRICS
);
143 SystemParametersInfo(SPI_GETNONCLIENTMETRICS
, 0, &ncm
, 0);
145 LogFont
= ncm
.lfMessageFont
;
146 LogFont
.lfWeight
= FW_BOLD
;
147 _tcscpy(LogFont
.lfFaceName
, _T("MS Shell Dlg"));
151 LogFont
.lfHeight
= 0 - GetDeviceCaps (hdc
, LOGPIXELSY
) * FontSize
/ 72;
152 hFont
= CreateFontIndirect(&LogFont
);
153 ReleaseDC(NULL
, hdc
);
159 InitImageInfo(PIMGINFO ImgInfo
)
163 ZeroMemory(ImgInfo
, sizeof(*ImgInfo
));
165 ImgInfo
->hBitmap
= LoadImage(hInstance
,
166 MAKEINTRESOURCE(IDB_ROSLOGO
),
172 if (ImgInfo
->hBitmap
!= NULL
)
174 GetObject(ImgInfo
->hBitmap
, sizeof(BITMAP
), &bitmap
);
176 ImgInfo
->cxSource
= bitmap
.bmWidth
;
177 ImgInfo
->cySource
= bitmap
.bmHeight
;
181 static INT_PTR CALLBACK
182 StartDlgProc(HWND hwndDlg
,
194 hwndControl
= GetParent(hwndDlg
);
196 /* Center the wizard window */
197 CenterWindow (hwndControl
);
199 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
200 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
202 /* Hide and disable the 'Cancel' button at the moment,
203 * we use this button to cancel the setup process
206 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
207 ShowWindow (hwndControl
, SW_HIDE
);
208 EnableWindow (hwndControl
, FALSE
);
211 SendDlgItemMessage(hwndDlg
,
221 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
226 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
242 static INT_PTR CALLBACK
243 LangSelDlgProc(HWND hwndDlg
,
253 pImgInfo
= (PIMGINFO
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
262 hwndControl
= GetParent(hwndDlg
);
264 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
265 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
267 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
268 ShowWindow (hwndControl
, SW_SHOW
);
269 EnableWindow (hwndControl
, TRUE
);
271 pImgInfo
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IMGINFO
));
272 if (pImgInfo
== NULL
)
274 EndDialog(hwndDlg
, 0);
278 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pImgInfo
);
280 InitImageInfo(pImgInfo
);
283 /*SendDlgItemMessage(hwndDlg,
289 hList
= GetDlgItem(hwndDlg
, IDC_LANGUAGES
);
291 for (i
=0; i
< SetupData
.LangCount
; i
++)
293 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) SetupData
.pLanguages
[i
].LangName
);
294 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
295 if (SetupData
.DefaultLang
== i
)
296 SendMessage(hList
, CB_SETCURSEL
, (WPARAM
) tindex
,(LPARAM
) 0);
299 hList
= GetDlgItem(hwndDlg
, IDC_KEYLAYOUT
);
301 for (i
=0; i
< SetupData
.KbLayoutCount
; i
++)
303 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
)SetupData
.pKbLayouts
[i
].LayoutName
);
304 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
305 if (SetupData
.DefaultKBLayout
== i
)
306 SendMessage(hList
,CB_SETCURSEL
,(WPARAM
)tindex
,(LPARAM
)0);
313 LPDRAWITEMSTRUCT lpDrawItem
;
314 lpDrawItem
= (LPDRAWITEMSTRUCT
) lParam
;
316 if (lpDrawItem
->CtlID
== IDB_ROSLOGO
)
321 /* position image in centre of dialog */
322 left
= (lpDrawItem
->rcItem
.right
- pImgInfo
->cxSource
) / 2;
324 hdcMem
= CreateCompatibleDC(lpDrawItem
->hDC
);
327 SelectObject(hdcMem
, pImgInfo
->hBitmap
);
328 BitBlt(lpDrawItem
->hDC
,
330 lpDrawItem
->rcItem
.top
,
331 lpDrawItem
->rcItem
.right
- lpDrawItem
->rcItem
.left
,
332 lpDrawItem
->rcItem
.bottom
- lpDrawItem
->rcItem
.top
,
345 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
350 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
353 case PSN_QUERYCANCEL
:
354 SetWindowLongPtr(hwndDlg
,
356 MessageBox(GetParent(hwndDlg
),
359 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
362 case PSN_WIZNEXT
: // set the selected data
364 hList
=GetDlgItem(hwndDlg
, IDC_LANGUAGES
);
365 tindex
= SendMessage(hList
,CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
367 if (tindex
!= CB_ERR
)
370 SetupData
.SelectedLangId
= SendMessage(hList
, CB_GETITEMDATA
, (WPARAM
) tindex
, (LPARAM
) 0);
371 LangID
= _tcstol(SetupData
.pLanguages
[SetupData
.SelectedLangId
].LangId
, NULL
, 16);
372 SetThreadLocale(MAKELCID(LangID
, SORT_DEFAULT
));
373 // FIXME: need to reload all resource to force
374 // the new language setting
377 hList
= GetDlgItem(hwndDlg
, IDC_KEYLAYOUT
);
378 tindex
= SendMessage(hList
,CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
379 if (tindex
!= CB_ERR
)
381 SetupData
.SelectedKBLayout
= SendMessage(hList
, CB_GETITEMDATA
, (WPARAM
) tindex
, (LPARAM
) 0);
399 static INT_PTR CALLBACK
400 TypeDlgProc(HWND hwndDlg
,
412 hwndControl
= GetParent(hwndDlg
);
414 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
415 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
417 CheckDlgButton(hwndDlg
, IDC_INSTALL
, BST_CHECKED
);
420 /*SendDlgItemMessage(hwndDlg,
430 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
435 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
438 case PSN_QUERYCANCEL
:
439 SetWindowLongPtr(hwndDlg
,
441 MessageBox(GetParent(hwndDlg
),
444 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
447 case PSN_WIZNEXT
: // set the selected data
448 SetupData
.RepairUpdateFlag
= !(SendMessage(GetDlgItem(hwndDlg
, IDC_INSTALL
),
451 (LPARAM
) 0) == BST_CHECKED
);
467 static INT_PTR CALLBACK
468 DeviceDlgProc(HWND hwndDlg
,
484 hwndControl
= GetParent(hwndDlg
);
486 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
487 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
490 /*SendDlgItemMessage(hwndDlg,
496 hList
= GetDlgItem(hwndDlg
, IDC_COMPUTER
);
498 for (i
=0; i
< SetupData
.CompCount
; i
++)
500 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) SetupData
.pComputers
[i
].Value
);
501 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
503 SendMessage(hList
, CB_SETCURSEL
, 0, 0); // set first as default
505 hList
= GetDlgItem(hwndDlg
, IDC_DISPLAY
);
507 for (i
=0; i
< SetupData
.DispCount
; i
++)
509 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) SetupData
.pDisplays
[i
].Value
);
510 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
512 SendMessage(hList
, CB_SETCURSEL
, 0, 0); // set first as default
514 hList
= GetDlgItem(hwndDlg
, IDC_KEYBOARD
);
516 for (i
=0; i
< SetupData
.KeybCount
; i
++)
518 tindex
= SendMessage(hList
,CB_ADDSTRING
,(WPARAM
)0,(LPARAM
)SetupData
.pKeyboards
[i
].Value
);
519 SendMessage(hList
,CB_SETITEMDATA
,tindex
,i
);
521 SendMessage(hList
,CB_SETCURSEL
,0,0); // set first as default
527 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
532 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
535 case PSN_QUERYCANCEL
:
536 SetWindowLongPtr(hwndDlg
,
538 MessageBox(GetParent(hwndDlg
),
541 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
544 case PSN_WIZNEXT
: // set the selected data
546 hList
= GetDlgItem(hwndDlg
, IDC_COMPUTER
);
548 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
549 if (tindex
!= CB_ERR
)
551 SetupData
.SelectedComputer
= SendMessage(hList
,
557 hList
= GetDlgItem(hwndDlg
, IDC_DISPLAY
);
559 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
560 if (tindex
!= CB_ERR
)
562 SetupData
.SelectedDisplay
= SendMessage(hList
,
568 hList
=GetDlgItem(hwndDlg
, IDC_KEYBOARD
);
570 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
571 if (tindex
!= CB_ERR
)
573 SetupData
.SelectedKeyboard
= SendMessage(hList
,
594 static INT_PTR CALLBACK
595 MoreOptDlgProc(HWND hwndDlg
,
604 CheckDlgButton(hwndDlg
, IDC_INSTFREELDR
, BST_CHECKED
);
605 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
608 (LPARAM
) SetupData
.InstallDir
);
614 switch(LOWORD(wParam
))
618 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
620 (WPARAM
) sizeof(SetupData
.InstallDir
) / sizeof(TCHAR
),
621 (LPARAM
) SetupData
.InstallDir
);
623 EndDialog(hwndDlg
, IDOK
);
629 EndDialog(hwndDlg
, IDCANCEL
);
639 static INT_PTR CALLBACK
640 PartitionDlgProc(HWND hwndDlg
,
651 switch(LOWORD(wParam
))
654 EndDialog(hwndDlg
, IDOK
);
657 EndDialog(hwndDlg
, IDCANCEL
);
665 static INT_PTR CALLBACK
666 DriveDlgProc(HWND hwndDlg
,
674 SP_DEVINFO_DATA DevInfoData
;
684 hwndControl
= GetParent(hwndDlg
);
686 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
687 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
690 /*SendDlgItemMessage(hwndDlg,
696 h
= SetupDiGetClassDevs(&GUID_DEVCLASS_DISKDRIVE
, NULL
, NULL
, DIGCF_PRESENT
);
697 if (h
!= INVALID_HANDLE_VALUE
)
699 hList
=GetDlgItem(hwndDlg
, IDC_PARTITION
);
700 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
701 for (i
=0; SetupDiEnumDeviceInfo(h
, i
, &DevInfoData
); i
++)
704 LPTSTR buffer
= NULL
;
705 DWORD buffersize
= 0;
707 while (!SetupDiGetDeviceRegistryProperty(h
,
715 if (GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
717 if (buffer
) LocalFree(buffer
);
718 buffer
= LocalAlloc(LPTR
, buffersize
* 2);
725 SendMessage(hList
, LB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) buffer
);
729 SetupDiDestroyDeviceInfoList(h
);
737 switch(LOWORD(wParam
))
739 case IDC_PARTMOREOPTS
:
741 MAKEINTRESOURCE(IDD_BOOTOPTIONS
),
743 (DLGPROC
) MoreOptDlgProc
);
747 MAKEINTRESOURCE(IDD_PARTITION
),
749 (DLGPROC
) PartitionDlgProc
);
759 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
764 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
767 case PSN_QUERYCANCEL
:
768 SetWindowLongPtr(hwndDlg
,
770 MessageBox(GetParent(hwndDlg
),
773 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
790 static INT_PTR CALLBACK
791 SummaryDlgProc(HWND hwndDlg
,
803 hwndControl
= GetParent(hwndDlg
);
805 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
806 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
808 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
809 ShowWindow(hwndControl
, SW_HIDE
);
810 EnableWindow(hwndControl
, FALSE
);
813 /*SendDlgItemMessage(hwndDlg,
823 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
828 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
844 static INT_PTR CALLBACK
845 ProcessDlgProc(HWND hwndDlg
,
857 hwndControl
= GetParent(hwndDlg
);
859 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
860 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
862 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
863 ShowWindow(hwndControl
, SW_HIDE
);
864 EnableWindow(hwndControl
, FALSE
);
867 /*SendDlgItemMessage(hwndDlg,
877 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
882 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
883 // disable all buttons during installation process
884 // PropSheet_SetWizButtons(GetParent(hwndDlg), 0 );
901 static INT_PTR CALLBACK
902 RestartDlgProc(HWND hwndDlg
,
914 hwndControl
= GetParent(hwndDlg
);
916 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
917 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
920 /*SendDlgItemMessage(hwndDlg,
933 hWndProgress
= GetDlgItem(hwndDlg
, IDC_RESTART_PROGRESS
);
934 Position
= SendMessage(hWndProgress
, PBM_GETPOS
, 0, 0);
937 KillTimer(hwndDlg
, 1);
938 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_FINISH
);
942 SendMessage(hWndProgress
, PBM_SETPOS
, Position
+ 1, 0);
952 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
956 case PSN_SETACTIVE
: // Only "Finish" for closing the App
958 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
959 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETRANGE
, 0, MAKELPARAM(0, 300));
960 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETPOS
, 0, 0);
961 SetTimer(hwndDlg
, 1, 50, NULL
);
981 WCHAR szPath
[MAX_PATH
];
985 INFCONTEXT InfContext
;
986 //TCHAR szValue[MAX_PATH];
990 GetModuleFileNameW(NULL
,szPath
,MAX_PATH
);
991 ch
= strrchrW(szPath
,L
'\\');
995 wcscat(szPath
, L
"\\txtsetup.sif");
996 hTxtsetupSif
= SetupOpenInfFileW(szPath
, NULL
, INF_STYLE_OLDNT
, NULL
);
997 if (hTxtsetupSif
!= INVALID_HANDLE_VALUE
)
1000 SetupData
.LangCount
= SetupGetLineCount(hTxtsetupSif
, _T("Language"));
1001 if (SetupData
.LangCount
> 0)
1003 SetupData
.pLanguages
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LANG
) * SetupData
.LangCount
);
1004 if (SetupData
.pLanguages
!= NULL
)
1007 if (SetupFindFirstLine(hTxtsetupSif
, _T("Language"), NULL
, &InfContext
))
1011 SetupGetStringField(&InfContext
,
1013 SetupData
.pLanguages
[Count
].LangId
,
1014 sizeof(SetupData
.pLanguages
[Count
].LangId
) / sizeof(TCHAR
),
1017 SetupGetStringField(&InfContext
,
1019 SetupData
.pLanguages
[Count
].LangName
,
1020 sizeof(SetupData
.pLanguages
[Count
].LangName
) / sizeof(TCHAR
),
1024 while (SetupFindNextLine(&InfContext
, &InfContext
) && Count
< SetupData
.LangCount
);
1029 // get keyboard layout list
1030 SetupData
.KbLayoutCount
= SetupGetLineCount(hTxtsetupSif
, _T("KeyboardLayout"));
1031 if (SetupData
.KbLayoutCount
> 0)
1033 SetupData
.pKbLayouts
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(KBLAYOUT
) * SetupData
.KbLayoutCount
);
1034 if (SetupData
.pKbLayouts
!= NULL
)
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
.KbLayoutCount
);
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 SetupData
.CompCount
= LoadGenentry(hTxtsetupSif
,_T("Computer"),SetupData
.pComputers
,&InfContext
);
1090 SetupData
.DispCount
= LoadGenentry(hTxtsetupSif
,_T("Display"),SetupData
.pDisplays
,&InfContext
);
1092 // get keyboard list
1093 SetupData
.KeybCount
= LoadGenentry(hTxtsetupSif
, _T("Keyboard"),SetupData
.pKeyboards
,&InfContext
);
1095 // get install directory
1096 if (SetupFindFirstLine(hTxtsetupSif
, _T("SetupData"), _T("DefaultPath"), &InfContext
))
1098 SetupGetStringField(&InfContext
,
1100 SetupData
.InstallDir
,
1101 sizeof(SetupData
.InstallDir
) / sizeof(TCHAR
),
1104 SetupCloseInfFile(hTxtsetupSif
);
1108 LONG
LoadGenentry(HINF hinf
,PCTSTR name
,PGENENTRY gen
,PINFCONTEXT context
)
1112 TotalCount
= SetupGetLineCount(hinf
, name
);
1115 gen
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(GENENTRY
) * TotalCount
);
1118 if (SetupFindFirstLine(hinf
, name
, NULL
, context
))
1123 SetupGetStringField(context
,
1126 sizeof(gen
[Count
].Id
) / sizeof(TCHAR
),
1129 SetupGetStringField(context
,
1132 sizeof(gen
[Count
].Value
) / sizeof(TCHAR
),
1136 while (SetupFindNextLine(context
, context
) && Count
< TotalCount
);
1144 BOOL
isUnattendSetup()
1146 WCHAR szPath
[MAX_PATH
];
1148 HINF hUnattendedInf
;
1149 INFCONTEXT InfContext
;
1150 TCHAR szValue
[MAX_PATH
];
1155 GetModuleFileNameW(NULL
, szPath
, MAX_PATH
);
1156 ch
= strrchrW(szPath
, L
'\\');
1160 wcscat(szPath
, L
"\\unattend.inf");
1161 hUnattendedInf
= SetupOpenInfFileW(szPath
, NULL
, INF_STYLE_OLDNT
, NULL
);
1163 if (hUnattendedInf
!= INVALID_HANDLE_VALUE
)
1165 if (SetupFindFirstLine(hUnattendedInf
, _T("Unattend"), _T("UnattendSetupEnabled"),&InfContext
))
1167 if (SetupGetStringField(&InfContext
,
1170 sizeof(szValue
) / sizeof(TCHAR
),
1171 &LineLength
) && (_tcsicmp(szValue
, _T("yes")) == 0))
1173 result
= 1; // unattendSetup enabled
1174 // read values and store in SetupData
1177 SetupCloseInfFile(hUnattendedInf
);
1184 _tWinMain(HINSTANCE hInst
,
1185 HINSTANCE hPrevInstance
,
1189 PROPSHEETHEADER psh
;
1190 HPROPSHEETPAGE ahpsp
[8];
1191 PROPSHEETPAGE psp
= {0};
1194 isUnattend
= isUnattendSetup();
1198 LoadString(hInst
,IDS_ABORTSETUP
, abort_msg
, sizeof(abort_msg
)/sizeof(TCHAR
));
1199 LoadString(hInst
,IDS_ABORTSETUP2
, abort_title
,sizeof(abort_title
)/sizeof(TCHAR
));
1203 /* Create the Start page, until setup is working */
1204 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1205 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
1206 psp
.hInstance
= hInst
;
1208 psp
.pfnDlgProc
= StartDlgProc
;
1209 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_STARTPAGE
);
1210 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1212 /* Create language selection page */
1213 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1214 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1215 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_LANGTITLE
);
1216 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_LANGSUBTITLE
);
1217 psp
.hInstance
= hInst
;
1219 psp
.pfnDlgProc
= LangSelDlgProc
;
1220 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_LANGSELPAGE
);
1221 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1223 /* Create install type selection page */
1224 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1225 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1226 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_TYPETITLE
);
1227 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_TYPESUBTITLE
);
1228 psp
.hInstance
= hInst
;
1230 psp
.pfnDlgProc
= TypeDlgProc
;
1231 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_TYPEPAGE
);
1232 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1234 /* Create device settings page */
1235 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1236 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1237 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_DEVICETITLE
);
1238 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_DEVICESUBTITLE
);
1239 psp
.hInstance
= hInst
;
1241 psp
.pfnDlgProc
= DeviceDlgProc
;
1242 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DEVICEPAGE
);
1243 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1245 /* Create install device settings page / boot method / install directory */
1246 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1247 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1248 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_DRIVETITLE
);
1249 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_DRIVESUBTITLE
);
1250 psp
.hInstance
= hInst
;
1252 psp
.pfnDlgProc
= DriveDlgProc
;
1253 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DRIVEPAGE
);
1254 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1256 /* Create summary page */
1257 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1258 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1259 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_SUMMARYTITLE
);
1260 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_SUMMARYSUBTITLE
);
1261 psp
.hInstance
= hInst
;
1263 psp
.pfnDlgProc
= SummaryDlgProc
;
1264 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_SUMMARYPAGE
);
1265 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1268 /* Create installation progress page */
1269 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1270 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1271 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_PROCESSTITLE
);
1272 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_PROCESSSUBTITLE
);
1273 psp
.hInstance
= hInst
;
1275 psp
.pfnDlgProc
= ProcessDlgProc
;
1276 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_PROCESSPAGE
);
1277 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1281 /* Create finish to reboot page */
1282 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1283 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1284 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_RESTARTTITLE
);
1285 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_RESTARTSUBTITLE
);
1286 psp
.hInstance
= hInst
;
1288 psp
.pfnDlgProc
= RestartDlgProc
;
1289 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_RESTARTPAGE
);
1290 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1293 /* Create the property sheet */
1294 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
1295 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
;
1296 psh
.hInstance
= hInst
;
1297 psh
.hwndParent
= NULL
;
1298 psh
.nPages
= nPages
;
1301 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
1302 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
1304 /* Create title font */
1305 hTitleFont
= CreateTitleFont();
1307 /* Display the wizard */
1308 PropertySheet(&psh
);
1310 DeleteObject(hTitleFont
);