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.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS GUI first stage setup application
22 * FILE: base/setup/reactos/reactos.c
23 * PROGRAMMERS: Eric Kohl
25 * Dmitry Chapyshev (dmitry@reactos.org)
37 #include <wine/unicode.h>
41 /* GLOBALS ******************************************************************/
51 typedef struct _KBLAYOUT
54 TCHAR LayoutName
[128];
56 } KBLAYOUT
, *PKBLAYOUT
;
59 // generic entries with simple 1:1 mapping
60 typedef struct _GENENTRY
64 } GENENTRY
, *PGENENTRY
;
69 LONG DestDiskNumber
; // physical disk
70 LONG DestPartNumber
; // partition on disk
71 LONG DestPartSize
; // if partition doesn't exist, size of partition
72 LONG FSType
; // file system type on partition
73 LONG MBRInstallType
; // install bootloader
74 LONG FormatPart
; // type of format the partition
75 LONG SelectedLangId
; // selected language (table index)
76 LONG SelectedKBLayout
; // selected keyboard layout (table index)
77 TCHAR InstallDir
[MAX_PATH
]; // installation directory on hdd
78 LONG SelectedComputer
; // selected computer type (table index)
79 LONG SelectedDisplay
; // selected display type (table index)
80 LONG SelectedKeyboard
; // selected keyboard type (table index)
81 BOOLEAN RepairUpdateFlag
; // flag for update/repair an installed reactos
83 LONG DefaultLang
; // default language (table index)
86 LONG DefaultKBLayout
; // default keyboard layout (table index)
97 typedef struct _IMGINFO
102 } IMGINFO
, *PIMGINFO
;
104 TCHAR abort_msg
[512], abort_title
[64];
108 LONG
LoadGenentry(HINF hinf
,PCTSTR name
,PGENENTRY
*gen
,PINFCONTEXT context
);
110 /* FUNCTIONS ****************************************************************/
113 CenterWindow(HWND hWnd
)
119 hWndParent
= GetParent(hWnd
);
120 if (hWndParent
== NULL
)
121 hWndParent
= GetDesktopWindow();
123 GetWindowRect(hWndParent
, &rcParent
);
124 GetWindowRect(hWnd
, &rcWindow
);
128 ((rcParent
.right
- rcParent
.left
) - (rcWindow
.right
- rcWindow
.left
)) / 2,
129 ((rcParent
.bottom
- rcParent
.top
) - (rcWindow
.bottom
- rcWindow
.top
)) / 2,
136 CreateTitleFont(VOID
)
138 NONCLIENTMETRICS ncm
;
144 ncm
.cbSize
= sizeof(NONCLIENTMETRICS
);
145 SystemParametersInfo(SPI_GETNONCLIENTMETRICS
, 0, &ncm
, 0);
147 LogFont
= ncm
.lfMessageFont
;
148 LogFont
.lfWeight
= FW_BOLD
;
149 _tcscpy(LogFont
.lfFaceName
, _T("MS Shell Dlg"));
153 LogFont
.lfHeight
= 0 - GetDeviceCaps (hdc
, LOGPIXELSY
) * FontSize
/ 72;
154 hFont
= CreateFontIndirect(&LogFont
);
155 ReleaseDC(NULL
, hdc
);
161 InitImageInfo(PIMGINFO ImgInfo
)
165 ZeroMemory(ImgInfo
, sizeof(*ImgInfo
));
167 ImgInfo
->hBitmap
= LoadImage(hInstance
,
168 MAKEINTRESOURCE(IDB_ROSLOGO
),
174 if (ImgInfo
->hBitmap
!= NULL
)
176 GetObject(ImgInfo
->hBitmap
, sizeof(BITMAP
), &bitmap
);
178 ImgInfo
->cxSource
= bitmap
.bmWidth
;
179 ImgInfo
->cySource
= bitmap
.bmHeight
;
183 static INT_PTR CALLBACK
184 StartDlgProc(HWND hwndDlg
,
196 hwndControl
= GetParent(hwndDlg
);
198 /* Center the wizard window */
199 CenterWindow (hwndControl
);
201 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
202 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
204 /* Hide and disable the 'Cancel' button at the moment,
205 * we use this button to cancel the setup process
208 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
209 ShowWindow (hwndControl
, SW_HIDE
);
210 EnableWindow (hwndControl
, FALSE
);
213 SendDlgItemMessage(hwndDlg
,
223 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
228 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
244 static INT_PTR CALLBACK
245 LangSelDlgProc(HWND hwndDlg
,
255 pImgInfo
= (PIMGINFO
)GetWindowLongPtr(hwndDlg
, DWLP_USER
);
264 hwndControl
= GetParent(hwndDlg
);
266 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
267 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
269 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
270 ShowWindow (hwndControl
, SW_SHOW
);
271 EnableWindow (hwndControl
, TRUE
);
273 pImgInfo
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IMGINFO
));
274 if (pImgInfo
== NULL
)
276 EndDialog(hwndDlg
, 0);
280 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pImgInfo
);
282 InitImageInfo(pImgInfo
);
285 /*SendDlgItemMessage(hwndDlg,
291 hList
= GetDlgItem(hwndDlg
, IDC_LANGUAGES
);
293 for (i
=0; i
< SetupData
.LangCount
; i
++)
295 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) SetupData
.pLanguages
[i
].LangName
);
296 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
297 if (SetupData
.DefaultLang
== i
)
298 SendMessage(hList
, CB_SETCURSEL
, (WPARAM
) tindex
,(LPARAM
) 0);
301 hList
= GetDlgItem(hwndDlg
, IDC_KEYLAYOUT
);
303 for (i
=0; i
< SetupData
.KbLayoutCount
; i
++)
305 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
)SetupData
.pKbLayouts
[i
].LayoutName
);
306 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
307 if (SetupData
.DefaultKBLayout
== i
)
308 SendMessage(hList
,CB_SETCURSEL
,(WPARAM
)tindex
,(LPARAM
)0);
315 LPDRAWITEMSTRUCT lpDrawItem
;
316 lpDrawItem
= (LPDRAWITEMSTRUCT
) lParam
;
318 if (lpDrawItem
->CtlID
== IDB_ROSLOGO
)
323 /* position image in centre of dialog */
324 left
= (lpDrawItem
->rcItem
.right
- pImgInfo
->cxSource
) / 2;
326 hdcMem
= CreateCompatibleDC(lpDrawItem
->hDC
);
329 SelectObject(hdcMem
, pImgInfo
->hBitmap
);
330 BitBlt(lpDrawItem
->hDC
,
332 lpDrawItem
->rcItem
.top
,
333 lpDrawItem
->rcItem
.right
- lpDrawItem
->rcItem
.left
,
334 lpDrawItem
->rcItem
.bottom
- lpDrawItem
->rcItem
.top
,
347 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
352 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
355 case PSN_QUERYCANCEL
:
356 SetWindowLongPtr(hwndDlg
,
358 MessageBox(GetParent(hwndDlg
),
361 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
364 case PSN_WIZNEXT
: // set the selected data
366 hList
=GetDlgItem(hwndDlg
, IDC_LANGUAGES
);
367 tindex
= SendMessage(hList
,CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
369 if (tindex
!= CB_ERR
)
372 SetupData
.SelectedLangId
= SendMessage(hList
, CB_GETITEMDATA
, (WPARAM
) tindex
, (LPARAM
) 0);
373 LangID
= _tcstol(SetupData
.pLanguages
[SetupData
.SelectedLangId
].LangId
, NULL
, 16);
374 SetThreadLocale(MAKELCID(LangID
, SORT_DEFAULT
));
375 // FIXME: need to reload all resource to force
376 // the new language setting
379 hList
= GetDlgItem(hwndDlg
, IDC_KEYLAYOUT
);
380 tindex
= SendMessage(hList
,CB_GETCURSEL
, (WPARAM
)0, (LPARAM
)0);
381 if (tindex
!= CB_ERR
)
383 SetupData
.SelectedKBLayout
= SendMessage(hList
, CB_GETITEMDATA
, (WPARAM
) tindex
, (LPARAM
) 0);
401 static INT_PTR CALLBACK
402 TypeDlgProc(HWND hwndDlg
,
414 hwndControl
= GetParent(hwndDlg
);
416 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
417 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
419 CheckDlgButton(hwndDlg
, IDC_INSTALL
, BST_CHECKED
);
422 /*SendDlgItemMessage(hwndDlg,
432 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
437 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
440 case PSN_QUERYCANCEL
:
441 SetWindowLongPtr(hwndDlg
,
443 MessageBox(GetParent(hwndDlg
),
446 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
449 case PSN_WIZNEXT
: // set the selected data
450 SetupData
.RepairUpdateFlag
= !(SendMessage(GetDlgItem(hwndDlg
, IDC_INSTALL
),
453 (LPARAM
) 0) == BST_CHECKED
);
469 static INT_PTR CALLBACK
470 DeviceDlgProc(HWND hwndDlg
,
486 hwndControl
= GetParent(hwndDlg
);
488 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
489 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
492 /*SendDlgItemMessage(hwndDlg,
498 hList
= GetDlgItem(hwndDlg
, IDC_COMPUTER
);
500 for (i
=0; i
< SetupData
.CompCount
; i
++)
502 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) SetupData
.pComputers
[i
].Value
);
503 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
505 SendMessage(hList
, CB_SETCURSEL
, 0, 0); // set first as default
507 hList
= GetDlgItem(hwndDlg
, IDC_DISPLAY
);
509 for (i
=0; i
< SetupData
.DispCount
; i
++)
511 tindex
= SendMessage(hList
, CB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) SetupData
.pDisplays
[i
].Value
);
512 SendMessage(hList
, CB_SETITEMDATA
, tindex
, i
);
514 SendMessage(hList
, CB_SETCURSEL
, 0, 0); // set first as default
516 hList
= GetDlgItem(hwndDlg
, IDC_KEYBOARD
);
518 for (i
=0; i
< SetupData
.KeybCount
; i
++)
520 tindex
= SendMessage(hList
,CB_ADDSTRING
,(WPARAM
)0,(LPARAM
)SetupData
.pKeyboards
[i
].Value
);
521 SendMessage(hList
,CB_SETITEMDATA
,tindex
,i
);
523 SendMessage(hList
,CB_SETCURSEL
,0,0); // set first as default
529 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
534 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
537 case PSN_QUERYCANCEL
:
538 SetWindowLongPtr(hwndDlg
,
540 MessageBox(GetParent(hwndDlg
),
543 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
546 case PSN_WIZNEXT
: // set the selected data
548 hList
= GetDlgItem(hwndDlg
, IDC_COMPUTER
);
550 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
551 if (tindex
!= CB_ERR
)
553 SetupData
.SelectedComputer
= SendMessage(hList
,
559 hList
= GetDlgItem(hwndDlg
, IDC_DISPLAY
);
561 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
562 if (tindex
!= CB_ERR
)
564 SetupData
.SelectedDisplay
= SendMessage(hList
,
570 hList
=GetDlgItem(hwndDlg
, IDC_KEYBOARD
);
572 tindex
= SendMessage(hList
, CB_GETCURSEL
, (WPARAM
) 0, (LPARAM
) 0);
573 if (tindex
!= CB_ERR
)
575 SetupData
.SelectedKeyboard
= SendMessage(hList
,
596 static INT_PTR CALLBACK
597 MoreOptDlgProc(HWND hwndDlg
,
606 CheckDlgButton(hwndDlg
, IDC_INSTFREELDR
, BST_CHECKED
);
607 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
610 (LPARAM
) SetupData
.InstallDir
);
616 switch(LOWORD(wParam
))
620 SendMessage(GetDlgItem(hwndDlg
, IDC_PATH
),
622 (WPARAM
) sizeof(SetupData
.InstallDir
) / sizeof(TCHAR
),
623 (LPARAM
) SetupData
.InstallDir
);
625 EndDialog(hwndDlg
, IDOK
);
631 EndDialog(hwndDlg
, IDCANCEL
);
641 static INT_PTR CALLBACK
642 PartitionDlgProc(HWND hwndDlg
,
653 switch(LOWORD(wParam
))
656 EndDialog(hwndDlg
, IDOK
);
659 EndDialog(hwndDlg
, IDCANCEL
);
667 static INT_PTR CALLBACK
668 DriveDlgProc(HWND hwndDlg
,
676 SP_DEVINFO_DATA DevInfoData
;
686 hwndControl
= GetParent(hwndDlg
);
688 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
689 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
692 /*SendDlgItemMessage(hwndDlg,
698 h
= SetupDiGetClassDevs(&GUID_DEVCLASS_DISKDRIVE
, NULL
, NULL
, DIGCF_PRESENT
);
699 if (h
!= INVALID_HANDLE_VALUE
)
701 hList
=GetDlgItem(hwndDlg
, IDC_PARTITION
);
702 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
703 for (i
=0; SetupDiEnumDeviceInfo(h
, i
, &DevInfoData
); i
++)
706 LPTSTR buffer
= NULL
;
707 DWORD buffersize
= 0;
709 while (!SetupDiGetDeviceRegistryProperty(h
,
717 if (GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
719 if (buffer
) LocalFree(buffer
);
720 buffer
= LocalAlloc(LPTR
, buffersize
* 2);
727 SendMessage(hList
, LB_ADDSTRING
, (WPARAM
) 0, (LPARAM
) buffer
);
731 SetupDiDestroyDeviceInfoList(h
);
739 switch(LOWORD(wParam
))
741 case IDC_PARTMOREOPTS
:
743 MAKEINTRESOURCE(IDD_BOOTOPTIONS
),
745 (DLGPROC
) MoreOptDlgProc
);
749 MAKEINTRESOURCE(IDD_PARTITION
),
751 (DLGPROC
) PartitionDlgProc
);
761 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
766 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
769 case PSN_QUERYCANCEL
:
770 SetWindowLongPtr(hwndDlg
,
772 MessageBox(GetParent(hwndDlg
),
775 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
792 static INT_PTR CALLBACK
793 SummaryDlgProc(HWND hwndDlg
,
805 hwndControl
= GetParent(hwndDlg
);
807 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
808 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
811 /*SendDlgItemMessage(hwndDlg,
821 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
826 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
| PSWIZB_BACK
);
829 case PSN_QUERYCANCEL
:
830 SetWindowLongPtr(hwndDlg
,
832 MessageBox(GetParent(hwndDlg
),
835 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
850 static INT_PTR CALLBACK
851 ProcessDlgProc(HWND hwndDlg
,
863 hwndControl
= GetParent(hwndDlg
);
865 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
866 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
869 /*SendDlgItemMessage(hwndDlg,
879 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
884 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_NEXT
);
885 // disable all buttons during installation process
886 // PropSheet_SetWizButtons(GetParent(hwndDlg), 0 );
888 case PSN_QUERYCANCEL
:
889 SetWindowLongPtr(hwndDlg
,
891 MessageBox(GetParent(hwndDlg
),
894 MB_YESNO
| MB_ICONQUESTION
) != IDYES
);
910 static INT_PTR CALLBACK
911 RestartDlgProc(HWND hwndDlg
,
923 hwndControl
= GetParent(hwndDlg
);
925 dwStyle
= GetWindowLongPtr(hwndControl
, GWL_STYLE
);
926 SetWindowLongPtr(hwndControl
, GWL_STYLE
, dwStyle
& ~WS_SYSMENU
);
928 hwndControl
= GetDlgItem(GetParent(hwndDlg
), IDCANCEL
);
929 ShowWindow(hwndControl
, SW_HIDE
);
930 EnableWindow(hwndControl
, FALSE
);
933 /*SendDlgItemMessage(hwndDlg,
946 hWndProgress
= GetDlgItem(hwndDlg
, IDC_RESTART_PROGRESS
);
947 Position
= SendMessage(hWndProgress
, PBM_GETPOS
, 0, 0);
950 KillTimer(hwndDlg
, 1);
951 PropSheet_PressButton(GetParent(hwndDlg
), PSBTN_FINISH
);
955 SendMessage(hWndProgress
, PBM_SETPOS
, Position
+ 1, 0);
965 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
969 case PSN_SETACTIVE
: // Only "Finish" for closing the App
971 PropSheet_SetWizButtons(GetParent(hwndDlg
), PSWIZB_FINISH
);
972 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETRANGE
, 0, MAKELPARAM(0, 300));
973 SendDlgItemMessage(hwndDlg
, IDC_RESTART_PROGRESS
, PBM_SETPOS
, 0, 0);
974 SetTimer(hwndDlg
, 1, 50, NULL
);
994 WCHAR szPath
[MAX_PATH
];
998 INFCONTEXT InfContext
;
999 //TCHAR szValue[MAX_PATH];
1003 GetModuleFileNameW(NULL
,szPath
,MAX_PATH
);
1004 ch
= strrchrW(szPath
,L
'\\');
1008 wcscat(szPath
, L
"\\txtsetup.sif");
1009 hTxtsetupSif
= SetupOpenInfFileW(szPath
, NULL
, INF_STYLE_OLDNT
, NULL
);
1010 if (hTxtsetupSif
!= INVALID_HANDLE_VALUE
)
1012 // get language list
1013 SetupData
.LangCount
= SetupGetLineCount(hTxtsetupSif
, _T("Language"));
1014 if (SetupData
.LangCount
> 0)
1016 SetupData
.pLanguages
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(LANG
) * SetupData
.LangCount
);
1017 if (SetupData
.pLanguages
!= NULL
)
1020 if (SetupFindFirstLine(hTxtsetupSif
, _T("Language"), NULL
, &InfContext
))
1024 SetupGetStringField(&InfContext
,
1026 SetupData
.pLanguages
[Count
].LangId
,
1027 sizeof(SetupData
.pLanguages
[Count
].LangId
) / sizeof(TCHAR
),
1030 SetupGetStringField(&InfContext
,
1032 SetupData
.pLanguages
[Count
].LangName
,
1033 sizeof(SetupData
.pLanguages
[Count
].LangName
) / sizeof(TCHAR
),
1037 while (SetupFindNextLine(&InfContext
, &InfContext
) && Count
< SetupData
.LangCount
);
1042 // get keyboard layout list
1043 SetupData
.KbLayoutCount
= SetupGetLineCount(hTxtsetupSif
, _T("KeyboardLayout"));
1044 if (SetupData
.KbLayoutCount
> 0)
1046 SetupData
.pKbLayouts
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(KBLAYOUT
) * SetupData
.KbLayoutCount
);
1047 if (SetupData
.pKbLayouts
!= NULL
)
1050 if (SetupFindFirstLine(hTxtsetupSif
, _T("KeyboardLayout"), NULL
, &InfContext
))
1054 SetupGetStringField(&InfContext
,
1056 SetupData
.pKbLayouts
[Count
].LayoutId
,
1057 sizeof(SetupData
.pKbLayouts
[Count
].LayoutId
) / sizeof(TCHAR
),
1060 SetupGetStringField(&InfContext
,
1062 SetupData
.pKbLayouts
[Count
].LayoutName
,
1063 sizeof(SetupData
.pKbLayouts
[Count
].LayoutName
) / sizeof(TCHAR
),
1067 while (SetupFindNextLine(&InfContext
, &InfContext
) && Count
< SetupData
.KbLayoutCount
);
1072 // get default for keyboard and language
1073 SetupData
.DefaultKBLayout
= -1;
1074 SetupData
.DefaultLang
= -1;
1076 // TODO: get defaults from underlaying running system
1077 if (SetupFindFirstLine(hTxtsetupSif
, _T("NLS"), _T("DefaultLayout"), &InfContext
))
1079 SetupGetStringField(&InfContext
, 1, tmp
, sizeof(tmp
) / sizeof(TCHAR
), &LineLength
);
1080 for (Count
= 0; Count
< SetupData
.KbLayoutCount
; Count
++)
1081 if (_tcscmp(tmp
, SetupData
.pKbLayouts
[Count
].LayoutId
) == 0)
1083 SetupData
.DefaultKBLayout
= Count
;
1088 if (SetupFindFirstLine(hTxtsetupSif
, _T("NLS"), _T("DefaultLanguage"), &InfContext
))
1090 SetupGetStringField(&InfContext
, 1, tmp
, sizeof(tmp
) / sizeof(TCHAR
), &LineLength
);
1091 for (Count
= 0; Count
< SetupData
.LangCount
; Count
++)
1092 if (_tcscmp(tmp
, SetupData
.pLanguages
[Count
].LangId
) == 0)
1094 SetupData
.DefaultLang
= Count
;
1099 // get computers list
1100 SetupData
.CompCount
= LoadGenentry(hTxtsetupSif
,_T("Computer"),&SetupData
.pComputers
,&InfContext
);
1103 SetupData
.DispCount
= LoadGenentry(hTxtsetupSif
,_T("Display"),&SetupData
.pDisplays
,&InfContext
);
1105 // get keyboard list
1106 SetupData
.KeybCount
= LoadGenentry(hTxtsetupSif
, _T("Keyboard"),&SetupData
.pKeyboards
,&InfContext
);
1108 // get install directory
1109 if (SetupFindFirstLine(hTxtsetupSif
, _T("SetupData"), _T("DefaultPath"), &InfContext
))
1111 SetupGetStringField(&InfContext
,
1113 SetupData
.InstallDir
,
1114 sizeof(SetupData
.InstallDir
) / sizeof(TCHAR
),
1117 SetupCloseInfFile(hTxtsetupSif
);
1121 LONG
LoadGenentry(HINF hinf
,PCTSTR name
,PGENENTRY
*gen
,PINFCONTEXT context
)
1126 TotalCount
= SetupGetLineCount(hinf
, name
);
1129 *gen
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(GENENTRY
) * TotalCount
);
1132 if (SetupFindFirstLine(hinf
, name
, NULL
, context
))
1137 SetupGetStringField(context
,
1140 sizeof((*gen
)[Count
].Id
) / sizeof(TCHAR
),
1143 SetupGetStringField(context
,
1145 (*gen
)[Count
].Value
,
1146 sizeof((*gen
)[Count
].Value
) / sizeof(TCHAR
),
1150 while (SetupFindNextLine(context
, context
) && Count
< TotalCount
);
1158 BOOL
isUnattendSetup()
1160 WCHAR szPath
[MAX_PATH
];
1162 HINF hUnattendedInf
;
1163 INFCONTEXT InfContext
;
1164 TCHAR szValue
[MAX_PATH
];
1169 GetModuleFileNameW(NULL
, szPath
, MAX_PATH
);
1170 ch
= strrchrW(szPath
, L
'\\');
1174 wcscat(szPath
, L
"\\unattend.inf");
1175 hUnattendedInf
= SetupOpenInfFileW(szPath
, NULL
, INF_STYLE_OLDNT
, NULL
);
1177 if (hUnattendedInf
!= INVALID_HANDLE_VALUE
)
1179 if (SetupFindFirstLine(hUnattendedInf
, _T("Unattend"), _T("UnattendSetupEnabled"),&InfContext
))
1181 if (SetupGetStringField(&InfContext
,
1184 sizeof(szValue
) / sizeof(TCHAR
),
1185 &LineLength
) && (_tcsicmp(szValue
, _T("yes")) == 0))
1187 result
= 1; // unattendSetup enabled
1188 // read values and store in SetupData
1191 SetupCloseInfFile(hUnattendedInf
);
1198 _tWinMain(HINSTANCE hInst
,
1199 HINSTANCE hPrevInstance
,
1203 PROPSHEETHEADER psh
;
1204 HPROPSHEETPAGE ahpsp
[8];
1205 PROPSHEETPAGE psp
= {0};
1208 isUnattend
= isUnattendSetup();
1210 LoadString(hInst
,IDS_ABORTSETUP
, abort_msg
, sizeof(abort_msg
)/sizeof(TCHAR
));
1211 LoadString(hInst
,IDS_ABORTSETUP2
, abort_title
,sizeof(abort_title
)/sizeof(TCHAR
));
1217 /* Create the Start page, until setup is working */
1218 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1219 psp
.dwFlags
= PSP_DEFAULT
| PSP_HIDEHEADER
;
1220 psp
.hInstance
= hInst
;
1222 psp
.pfnDlgProc
= StartDlgProc
;
1223 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_STARTPAGE
);
1224 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1226 /* Create language selection page */
1227 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1228 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1229 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_LANGTITLE
);
1230 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_LANGSUBTITLE
);
1231 psp
.hInstance
= hInst
;
1233 psp
.pfnDlgProc
= LangSelDlgProc
;
1234 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_LANGSELPAGE
);
1235 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1237 /* Create install type selection page */
1238 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1239 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1240 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_TYPETITLE
);
1241 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_TYPESUBTITLE
);
1242 psp
.hInstance
= hInst
;
1244 psp
.pfnDlgProc
= TypeDlgProc
;
1245 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_TYPEPAGE
);
1246 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1248 /* Create device settings page */
1249 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1250 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1251 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_DEVICETITLE
);
1252 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_DEVICESUBTITLE
);
1253 psp
.hInstance
= hInst
;
1255 psp
.pfnDlgProc
= DeviceDlgProc
;
1256 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DEVICEPAGE
);
1257 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1259 /* Create install device settings page / boot method / install directory */
1260 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1261 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1262 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_DRIVETITLE
);
1263 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_DRIVESUBTITLE
);
1264 psp
.hInstance
= hInst
;
1266 psp
.pfnDlgProc
= DriveDlgProc
;
1267 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_DRIVEPAGE
);
1268 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1270 /* Create summary page */
1271 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1272 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1273 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_SUMMARYTITLE
);
1274 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_SUMMARYSUBTITLE
);
1275 psp
.hInstance
= hInst
;
1277 psp
.pfnDlgProc
= SummaryDlgProc
;
1278 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_SUMMARYPAGE
);
1279 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1282 /* Create installation progress page */
1283 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1284 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1285 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_PROCESSTITLE
);
1286 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_PROCESSSUBTITLE
);
1287 psp
.hInstance
= hInst
;
1289 psp
.pfnDlgProc
= ProcessDlgProc
;
1290 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_PROCESSPAGE
);
1291 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1293 /* Create finish to reboot page */
1294 psp
.dwSize
= sizeof(PROPSHEETPAGE
);
1295 psp
.dwFlags
= PSP_DEFAULT
| PSP_USEHEADERTITLE
| PSP_USEHEADERSUBTITLE
;
1296 psp
.pszHeaderTitle
= MAKEINTRESOURCE(IDS_RESTARTTITLE
);
1297 psp
.pszHeaderSubTitle
= MAKEINTRESOURCE(IDS_RESTARTSUBTITLE
);
1298 psp
.hInstance
= hInst
;
1300 psp
.pfnDlgProc
= RestartDlgProc
;
1301 psp
.pszTemplate
= MAKEINTRESOURCE(IDD_RESTARTPAGE
);
1302 ahpsp
[nPages
++] = CreatePropertySheetPage(&psp
);
1304 /* Create the property sheet */
1305 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
1306 psh
.dwFlags
= PSH_WIZARD97
| PSH_WATERMARK
| PSH_HEADER
;
1307 psh
.hInstance
= hInst
;
1308 psh
.hwndParent
= NULL
;
1309 psh
.nPages
= nPages
;
1312 psh
.pszbmWatermark
= MAKEINTRESOURCE(IDB_WATERMARK
);
1313 psh
.pszbmHeader
= MAKEINTRESOURCE(IDB_HEADER
);
1315 /* Create title font */
1316 hTitleFont
= CreateTitleFont();
1318 /* Display the wizard */
1319 PropertySheet(&psh
);
1321 DeleteObject(hTitleFont
);