Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

261 lines
8.2 KiB

  1. /****************************************************************************\
  2. MODE.C / OPK Wizard (OPKWIZ.EXE)
  3. Microsoft Confidential
  4. Copyright (c) Microsoft Corporation 1998
  5. All rights reserved
  6. Source file for the OPK Wizard that contains the external and internal
  7. functions used by the "mode select" wizard page.
  8. 4/99 - Jason Cohen (JCOHEN)
  9. Added this new source file for the OPK Wizard as part of the
  10. Millennium rewrite.
  11. 09/2000 - Stephen Lodwick (STELO)
  12. Ported OPK Wizard to Whistler
  13. \****************************************************************************/
  14. //
  15. // Include File(s):
  16. //
  17. #include "pch.h"
  18. #include "wizard.h"
  19. #include "resource.h"
  20. //
  21. // Internal Defined Value(s):
  22. //
  23. #define INI_KEY_MODE _T("Mode")
  24. #define INI_KEY_RESEAL _T("Reseal")
  25. #define INI_VAL_ADVANCED 1
  26. #define INI_VAL_ENHANCED 2
  27. #define INI_VAL_SADVANCED STR_ONE
  28. #define INI_VAL_SSTANDARD STR_ZERO
  29. #define INI_VAL_SENHANCED _T("2")
  30. //
  31. // Internal Function Prototype(s):
  32. //
  33. static BOOL OnInit(HWND, HWND, LPARAM);
  34. static void OnCommand(HWND hwnd, INT id, HWND hwndCtl, UINT codeNotify);
  35. static void OnNext(HWND);
  36. static void EnableControls(HWND hwnd);
  37. //
  38. // External Function(s):
  39. //
  40. LRESULT CALLBACK ModeDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  41. {
  42. switch (uMsg)
  43. {
  44. HANDLE_MSG(hwnd, WM_INITDIALOG, OnInit);
  45. HANDLE_MSG(hwnd, WM_COMMAND, OnCommand);
  46. case WM_NOTIFY:
  47. switch ( ((NMHDR FAR *) lParam)->code )
  48. {
  49. case PSN_KILLACTIVE:
  50. case PSN_RESET:
  51. case PSN_WIZBACK:
  52. case PSN_WIZFINISH:
  53. break;
  54. case PSN_WIZNEXT:
  55. OnNext(hwnd);
  56. break;
  57. case PSN_QUERYCANCEL:
  58. WIZ_CANCEL(hwnd);
  59. break;
  60. case PSN_HELP:
  61. WIZ_HELP();
  62. break;
  63. case PSN_SETACTIVE:
  64. g_App.dwCurrentHelp = IDH_MODESEL;
  65. WIZ_BUTTONS(hwnd, PSWIZB_NEXT);
  66. // Press next if the user is in auto mode
  67. //
  68. WIZ_NEXTONAUTO(hwnd, PSBTN_NEXT);
  69. break;
  70. default:
  71. return FALSE;
  72. }
  73. break;
  74. default:
  75. return FALSE;
  76. }
  77. return TRUE;
  78. }
  79. //
  80. // Internal Function(s):
  81. //
  82. static BOOL OnInit(HWND hwnd, HWND hwndFocus, LPARAM lParam)
  83. {
  84. INT iStrings[] =
  85. {
  86. IDS_RESEAL_FACTORY,
  87. IDS_RESEAL_OOBE,
  88. };
  89. TCHAR szScratch[256];
  90. DWORD dwIndex;
  91. LPTSTR lpString;
  92. // Set the flag because we want to warn before exiting
  93. //
  94. SET_FLAG(OPK_EXIT, FALSE);
  95. // Setup the combo box.
  96. //
  97. for ( dwIndex = 0; dwIndex < AS(iStrings); dwIndex++ )
  98. {
  99. if ( lpString = AllocateString(NULL, iStrings[dwIndex]) )
  100. {
  101. SendDlgItemMessage(hwnd, IDC_RESEAL_COMBO, CB_ADDSTRING, 0, (LPARAM) lpString);
  102. FREE(lpString);
  103. }
  104. }
  105. SendDlgItemMessage(hwnd, IDC_RESEAL_COMBO, CB_SETCURSEL, 0, 0L);
  106. // Determine the mode that we are going to use (different
  107. // for batch mode).
  108. //
  109. if ( GET_FLAG(OPK_BATCHMODE) )
  110. {
  111. // In Batch we use the opkwiz inf file.
  112. //
  113. switch ( GetPrivateProfileInt(INI_SEC_GENERAL, INI_KEY_MODE, 0, g_App.szOpkWizIniFile) )
  114. {
  115. // Check the necessary radio button
  116. //
  117. case INI_VAL_ADVANCED:
  118. CheckRadioButton(hwnd, IDC_STANDARD, IDC_ADVANCED, IDC_ADVANCED);
  119. break;
  120. case INI_VAL_ENHANCED:
  121. CheckRadioButton(hwnd, IDC_STANDARD, IDC_ADVANCED, IDC_EXPRESS);
  122. if ( GetPrivateProfileInt(INI_SEC_GENERAL, INI_KEY_RESEAL, 0, g_App.szOpkWizIniFile) == 1 )
  123. SendDlgItemMessage(hwnd, IDC_RESEAL_COMBO, CB_SETCURSEL, 1, 0L);
  124. break;
  125. default:
  126. CheckRadioButton(hwnd, IDC_STANDARD, IDC_ADVANCED, IDC_STANDARD);
  127. }
  128. }
  129. else
  130. {
  131. // Normally we just look in the winbom.
  132. //
  133. szScratch[0] = NULLCHR;
  134. GetPrivateProfileString(WBOM_WINPE_SECTION, INI_KEY_WBOM_WINPE_RESTART, NULLSTR, szScratch, AS(szScratch), g_App.szWinBomIniFile);
  135. if ( LSTRCMPI(szScratch, INI_VAL_WBOM_WINPE_IMAGE) == 0 )
  136. {
  137. // If the image key is in the winbom, must be an advanced install.
  138. //
  139. CheckRadioButton(hwnd, IDC_STANDARD, IDC_ADVANCED, IDC_ADVANCED);
  140. }
  141. else
  142. {
  143. // Need to check another key to see if it is express or standard.
  144. //
  145. szScratch[0] = NULLCHR;
  146. GetPrivateProfileString(WBOM_FACTORY_SECTION, INI_KEY_WBOM_FACTORY_RESEAL, NULLSTR, szScratch, AS(szScratch), g_App.szWinBomIniFile);
  147. if ( szScratch[0] && ( LSTRCMPI(szScratch, _T("No")) != 0 ) )
  148. {
  149. // They have reseal equal something other than NO, so they must
  150. // be doing and express install.
  151. //
  152. CheckRadioButton(hwnd, IDC_STANDARD, IDC_ADVANCED, IDC_EXPRESS);
  153. // Need to figure out the reseal mode option.
  154. //
  155. szScratch[0] = NULLCHR;
  156. GetPrivateProfileString(WBOM_FACTORY_SECTION, INI_KEY_WBOM_FACTORY_RESEALMODE, NULLSTR, szScratch, AS(szScratch), g_App.szWinBomIniFile);
  157. if ( ( szScratch[0] == NULLCHR ) ||
  158. ( LSTRCMPI(szScratch, INI_VAL_WBOM_FACTORY) != 0 ) )
  159. {
  160. // They don't have the mode set to factory, so it must be end user
  161. // boot (it was already set to factory by default so nothing to do
  162. // if that is what the reseal mode key says).
  163. //
  164. SendDlgItemMessage(hwnd, IDC_RESEAL_COMBO, CB_SETCURSEL, 1, 0L);
  165. }
  166. }
  167. else
  168. {
  169. // No reseal, so this is just a standard install.
  170. //
  171. CheckRadioButton(hwnd, IDC_STANDARD, IDC_ADVANCED, IDC_STANDARD);
  172. }
  173. }
  174. }
  175. // Make sure the proper controls are enabled/disabled.
  176. //
  177. EnableControls(hwnd);
  178. // Always return false to WM_INITDIALOG.
  179. //
  180. return FALSE;
  181. }
  182. static void OnCommand(HWND hwnd, INT id, HWND hwndCtl, UINT codeNotify)
  183. {
  184. switch ( id )
  185. {
  186. case IDC_STANDARD:
  187. case IDC_EXPRESS:
  188. case IDC_ADVANCED:
  189. EnableControls(hwnd);
  190. break;
  191. }
  192. }
  193. static void OnNext(HWND hwnd)
  194. {
  195. BOOL bAdvanced = ( IsDlgButtonChecked(hwnd, IDC_ADVANCED) == BST_CHECKED ),
  196. bExpress = ( !bAdvanced && ( IsDlgButtonChecked(hwnd, IDC_EXPRESS) == BST_CHECKED ) ),
  197. bEndUser = ( bExpress && ( SendDlgItemMessage(hwnd, IDC_RESEAL_COMBO, CB_GETCURSEL, 0, 0L) == 1 ) );
  198. // Write out the mode to the opkwiz inf and winbom files.
  199. //
  200. WritePrivateProfileString(WBOM_WINPE_SECTION, INI_KEY_WBOM_WINPE_RESTART, ( bAdvanced ? INI_VAL_WBOM_WINPE_IMAGE : INI_VAL_WBOM_WINPE_REBOOT ), g_App.szWinBomIniFile);
  201. WritePrivateProfileString(INI_SEC_GENERAL, INI_KEY_MODE, ( bAdvanced ? INI_VAL_SADVANCED : ( bExpress ? INI_VAL_SENHANCED : INI_VAL_SSTANDARD ) ), g_App.szOpkWizIniFile);
  202. // Now if this is express write out what is in the combo box
  203. // to the opkwiz inf and winbom files.
  204. //
  205. WritePrivateProfileString(INI_SEC_GENERAL, INI_KEY_RESEAL, ( bEndUser ? STR_ONE : NULL ), g_App.szOpkWizIniFile);
  206. WritePrivateProfileString(WBOM_FACTORY_SECTION, INI_KEY_WBOM_FACTORY_RESEAL, ( bExpress ? _T("Yes") : NULL ), g_App.szWinBomIniFile);
  207. WritePrivateProfileString(WBOM_FACTORY_SECTION, INI_KEY_WBOM_FACTORY_RESEALMODE, ( ( bExpress && !bEndUser ) ? INI_VAL_WBOM_FACTORY : NULL ), g_App.szWinBomIniFile);
  208. }
  209. static void EnableControls(HWND hwnd)
  210. {
  211. BOOL fEnable = ( IsDlgButtonChecked(hwnd, IDC_EXPRESS) == BST_CHECKED );
  212. EnableWindow(GetDlgItem(hwnd, IDC_RESEAL_TEXT), fEnable);
  213. EnableWindow(GetDlgItem(hwnd, IDC_RESEAL_COMBO), fEnable);
  214. }