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.

1685 lines
52 KiB

  1. #include "setupp.h"
  2. #pragma hdrstop
  3. #ifdef _OCM
  4. #include <ocmanage.h>
  5. #include <ocmgrlib.h>
  6. #endif
  7. extern BOOLEAN
  8. AsrIsEnabled( VOID );
  9. typedef struct _WIZPAGE {
  10. UINT ButtonState;
  11. UINT Spare;
  12. PROPSHEETPAGE Page;
  13. } WIZPAGE, *PWIZPAGE;
  14. BOOL UiTest;
  15. //
  16. // "Page" that is actually a signal to fetch the net pages
  17. // and insert them there.
  18. //
  19. #define WizPagePlaceholderNet (WizPageMaximum+1)
  20. #define WizPagePlaceholderLic (WizPageMaximum+2)
  21. BOOL NetWizard;
  22. #ifdef _OCM
  23. #define WizPageOcManager (WizPageMaximum+3)
  24. #define WizPageOcManagerSetup (WizPageMaximum+4)
  25. #define WizPageOcManagerEarly (WizPageMaximum+5)
  26. #define WizPageOcManagerPrenet (WizPageMaximum+6)
  27. #define WizPageOcManagerPostnet (WizPageMaximum+7)
  28. #define WizPageOcManagerLate (WizPageMaximum+8)
  29. #endif
  30. #define MAX_LICWIZ_PAGES MAX_NETWIZ_PAGES
  31. #define LICENSESETUPPAGEREQUESTPROCNAME "LicenseSetupRequestWizardPages"
  32. //
  33. // These MUST be in the same order as the items in the WizPage enum!!!
  34. //
  35. WIZPAGE SetupWizardPages[WizPageMaximum] = {
  36. //
  37. // Welcome page
  38. //
  39. {
  40. PSWIZB_NEXT,
  41. 0,
  42. { sizeof(PROPSHEETPAGE), // size of struct
  43. PSP_HIDEHEADER, // full-size page, no header
  44. NULL, // hinst (filled in at run time)
  45. MAKEINTRESOURCE(IDD_WELCOME), // dlg template
  46. NULL, // icon
  47. NULL, // title
  48. WelcomeDlgProc, // dlg proc
  49. 0, // lparam
  50. NULL, // callback
  51. NULL // ref count
  52. }},
  53. //
  54. // EULA page
  55. //
  56. {
  57. PSWIZB_NEXT | PSWIZB_BACK,
  58. 0,
  59. { sizeof(PROPSHEETPAGE), // size of struct
  60. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  61. NULL, // hinst (filled in at run time)
  62. MAKEINTRESOURCE(IDD_EULA), // dlg template
  63. NULL, // icon
  64. NULL, // title
  65. EulaDlgProc, // dlg proc
  66. 0, // lparam
  67. NULL, // callback
  68. NULL, // ref count
  69. (LPCWSTR)IDS_EULA, // title
  70. (LPCWSTR)IDS_EULA_SUB, // subtitle
  71. }},
  72. //
  73. // Preparing Directory page
  74. //
  75. {
  76. PSWIZB_NEXT | PSWIZB_BACK,
  77. 0,
  78. { sizeof(PROPSHEETPAGE), // size of struct
  79. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  80. NULL, // hinst (filled in at run time)
  81. MAKEINTRESOURCE(IDD_PREPARING), // dlg template
  82. NULL, // icon
  83. NULL, // title
  84. PreparingDlgProc, // dlg proc
  85. 0, // lparam
  86. NULL, // callback
  87. NULL, // ref count
  88. (LPCWSTR)IDS_PREPARING_INSTALL, // title
  89. (LPCWSTR)IDS_PREPARING_INSTALL_SUB, // subtitle
  90. }},
  91. //
  92. // Preparing ASR page
  93. //
  94. {
  95. PSWIZB_NEXT | PSWIZB_BACK,
  96. 0,
  97. { sizeof(PROPSHEETPAGE), // size of struct
  98. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE, NULL, // hinst (filled in at run time)
  99. MAKEINTRESOURCE(IDD_PREPARING_ASR), // dlg template
  100. NULL, // icon
  101. NULL, // title
  102. PreparingDlgProc, // dlg proc
  103. 0, // lparam
  104. NULL, // callback
  105. NULL, // ref count
  106. (LPCWSTR)IDS_ASR, // title
  107. (LPCWSTR)IDS_ASR_SUB, // subtitle
  108. }},
  109. #ifdef PNP_DEBUG_UI
  110. //
  111. // Installed Hardware page
  112. //
  113. {
  114. PSWIZB_NEXT | PSWIZB_BACK,
  115. 0,
  116. { sizeof(PROPSHEETPAGE), // size of struct
  117. 0, // flags
  118. NULL, // hinst (filled in at run time)
  119. MAKEINTRESOURCE(IDD_HARDWARE), // dlg template
  120. NULL, // icon
  121. NULL, // title
  122. InstalledHardwareDlgProc, // dlg proc
  123. 0, // lparam
  124. NULL, // callback
  125. NULL // ref count
  126. }},
  127. #endif // PNP_DEBUG_UI
  128. //
  129. // International settings (locale, kbd layout) page
  130. //
  131. {
  132. PSWIZB_NEXT | PSWIZB_BACK,
  133. 0,
  134. { sizeof(PROPSHEETPAGE), // size of struct
  135. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  136. NULL, // hInst (filled in at run time)
  137. MAKEINTRESOURCE(IDD_REGIONAL_SETTINGS), // dlg template
  138. NULL, // icon
  139. NULL, // title
  140. RegionalSettingsDlgProc, // dlg proc
  141. 0, // lparam
  142. NULL, // callback
  143. NULL, // ref count
  144. (LPCWSTR)IDS_REGIONAL_SETTINGS,
  145. (LPCWSTR)IDS_REGIONAL_SETTINGS_SUB
  146. }},
  147. //
  148. // Name/organization page
  149. //
  150. {
  151. PSWIZB_NEXT | PSWIZB_BACK,
  152. 0,
  153. { sizeof(PROPSHEETPAGE), // size of struct
  154. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  155. NULL, // hinst (filled in at run time)
  156. MAKEINTRESOURCE(IDD_NAMEORG), // dlg template
  157. NULL, // icon
  158. NULL, // title
  159. NameOrgDlgProc, // dlg proc
  160. 0, // lparam
  161. NULL, // callback
  162. NULL, // ref count
  163. (LPCWSTR)IDS_NAMEORG, // title
  164. (LPCWSTR)IDS_NAMEORG_SUB // subtitle
  165. }},
  166. //
  167. // Product id page for CD
  168. //
  169. {
  170. PSWIZB_NEXT | PSWIZB_BACK,
  171. 0,
  172. { sizeof(PROPSHEETPAGE), // size of struct
  173. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  174. NULL, // hinst (filled in at run time)
  175. MAKEINTRESOURCE(IDD_PID_CD), // dlg template
  176. NULL, // icon
  177. NULL, // title
  178. Pid30CDDlgProc, // dlg proc
  179. 0, // lparam
  180. NULL, // callback
  181. NULL, // ref count
  182. (LPCWSTR)IDS_PID, // title
  183. (LPCWSTR)IDS_PID_SUB // subtitle
  184. }},
  185. //
  186. // Product id page for OEM
  187. //
  188. {
  189. PSWIZB_NEXT | PSWIZB_BACK,
  190. 0,
  191. { sizeof(PROPSHEETPAGE), // size of struct
  192. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  193. NULL, // hinst (filled in at run time)
  194. MAKEINTRESOURCE(IDD_PID_OEM), // dlg template
  195. NULL, // icon
  196. NULL, // title
  197. Pid30OemDlgProc, // dlg proc
  198. 0, // lparam
  199. NULL, // callback
  200. NULL, // ref count
  201. (LPCWSTR)IDS_OEM, // title
  202. (LPCWSTR)IDS_OEM_SUB // subtitle
  203. }},
  204. //
  205. // Product id page for Select media
  206. //
  207. {
  208. PSWIZB_NEXT | PSWIZB_BACK,
  209. 0,
  210. { sizeof(PROPSHEETPAGE), // size of struct
  211. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  212. NULL, // hinst (filled in at run time)
  213. MAKEINTRESOURCE(IDD_PID_SELECT), // dlg template
  214. NULL, // icon
  215. NULL, // title
  216. Pid30SelectDlgProc, // dlg proc
  217. 0, // lparam
  218. NULL, // callback
  219. NULL, // ref count
  220. (LPCWSTR)IDS_SELECT, // title
  221. (LPCWSTR)IDS_SELECT_SUB // subtitle
  222. }},
  223. //
  224. // Computer name page
  225. //
  226. {
  227. PSWIZB_NEXT | PSWIZB_BACK,
  228. 0,
  229. { sizeof(PROPSHEETPAGE), // size of struct
  230. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  231. NULL, // hinst (filled in at run time)
  232. MAKEINTRESOURCE(IDD_COMPUTERNAME), // dlg template
  233. NULL, // icon
  234. NULL, // title
  235. ComputerNameDlgProc, // dlg proc
  236. 0, // lparam
  237. NULL, // callback
  238. NULL, // ref count
  239. (LPCWSTR)IDS_COMPUTERNAME, // title
  240. (LPCWSTR)IDS_COMPUTERNAME_SUB // subtitle
  241. }},
  242. #ifdef DOLOCALUSER
  243. //
  244. // Local user account page
  245. //
  246. {
  247. PSWIZB_NEXT | PSWIZB_BACK,
  248. 0,
  249. { sizeof(PROPSHEETPAGE), // size of struct
  250. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  251. NULL, // hinst (filled in at run time)
  252. MAKEINTRESOURCE(IDD_USERACCOUNT), // dlg template
  253. NULL, // icon
  254. NULL, // title
  255. UserAccountDlgProc, // dlg proc
  256. 0, // lparam
  257. NULL, // callback
  258. NULL, // ref count
  259. (LPCWSTR)IDS_USERNAME, // title
  260. (LPCWSTR)IDS_USERNAME_SUB // subtitle
  261. }},
  262. #endif
  263. #ifdef _X86_
  264. //
  265. // Pentium errata page (x86 only)
  266. //
  267. {
  268. PSWIZB_NEXT | PSWIZB_BACK,
  269. 0,
  270. { sizeof(PROPSHEETPAGE), // size of struct
  271. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  272. NULL, // hinst (filled in at run time)
  273. MAKEINTRESOURCE(IDD_PENTIUM), // dlg template
  274. NULL, // icon
  275. NULL, // title
  276. PentiumDlgProc, // dlg proc
  277. 0, // lparam
  278. NULL, // callback
  279. NULL, // ref count
  280. (LPCWSTR)IDS_FPERRATA, // title
  281. (LPCWSTR)IDS_FPERRATA_SUB // subtitle
  282. }},
  283. #endif // def _X86_
  284. //
  285. // Intermediate steps page
  286. //
  287. {
  288. PSWIZB_NEXT | PSWIZB_BACK,
  289. 0,
  290. { sizeof(PROPSHEETPAGE), // size of struct
  291. PSP_USEHEADERTITLE,
  292. NULL, // hinst (filled in at run time)
  293. MAKEINTRESOURCE(IDD_STEPS1), // dlg template
  294. NULL, // icon
  295. NULL, // title
  296. StepsDlgProc, // dlg proc
  297. 0, // lparam
  298. NULL, // callback
  299. NULL, // ref count
  300. (LPCWSTR)IDS_WINNT_SETUP // title
  301. }},
  302. {
  303. 0,
  304. 0,
  305. { sizeof(PROPSHEETPAGE), // size of struct
  306. PSP_USEHEADERTITLE,
  307. NULL, // hinst (filled in at run time)
  308. MAKEINTRESOURCE(IDD_STEPS1), // dlg template
  309. NULL, // icon
  310. NULL, // title
  311. SetupPreNetDlgProc, // dlg proc
  312. 0, // lparam
  313. NULL, // callback
  314. NULL, // ref count
  315. (LPCWSTR)IDS_WINNT_SETUP // title
  316. }},
  317. {
  318. 0,
  319. 0,
  320. { sizeof(PROPSHEETPAGE), // size of struct
  321. PSP_USEHEADERTITLE,
  322. NULL, // hinst (filled in at run time)
  323. MAKEINTRESOURCE(IDD_STEPS1), // dlg template
  324. NULL, // icon
  325. NULL, // title
  326. SetupPostNetDlgProc, // dlg proc
  327. 0, // lparam
  328. NULL, // callback
  329. NULL, // ref count
  330. (LPCWSTR)IDS_WINNT_SETUP // title
  331. }},
  332. //
  333. // Copying files page
  334. //
  335. {
  336. PSWIZB_NEXT | PSWIZB_BACK,
  337. 0,
  338. { sizeof(PROPSHEETPAGE), // size of struct
  339. PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE,
  340. NULL, // hinst (filled in at run time)
  341. MAKEINTRESOURCE(IDD_COPYFILES3), // dlg template
  342. NULL, // icon
  343. NULL, // title
  344. CopyFilesDlgProc, // dlg proc
  345. 0, // lparam
  346. NULL, // callback
  347. NULL, // ref count
  348. (LPCWSTR)IDS_COPYFILES, // title
  349. (LPCWSTR)IDS_COPYFILES_SUB2, // subtitle
  350. }},
  351. //
  352. // Last ASR page.
  353. //
  354. {
  355. PSWIZB_FINISH,
  356. 0,
  357. { sizeof(PROPSHEETPAGE), // size of struct
  358. PSP_HIDEHEADER, // full-size page, no header
  359. NULL, // hinst (filled in at run time)
  360. MAKEINTRESOURCE(IDD_LAST_ASR_PAGE), // dlg template
  361. NULL, // icon
  362. NULL, // title
  363. LastPageDlgProc, // dlg proc
  364. 0, // lparam
  365. NULL, // callback
  366. NULL, // ref count
  367. (LPCWSTR)IDS_WINNT_SETUP // title
  368. }},
  369. //
  370. // Last page.
  371. //
  372. {
  373. PSWIZB_FINISH,
  374. 0,
  375. { sizeof(PROPSHEETPAGE), // size of struct
  376. PSP_HIDEHEADER, // full-size page, no header
  377. NULL, // hinst (filled in at run time)
  378. MAKEINTRESOURCE(IDD_LAST_WIZARD_PAGE), // dlg template
  379. NULL, // icon
  380. NULL, // title
  381. LastPageDlgProc, // dlg proc
  382. 0, // lparam
  383. NULL, // callback
  384. NULL, // ref count
  385. (LPCWSTR)IDS_WINNT_SETUP // title
  386. }}
  387. };
  388. UINT InitialWizardPages[] = { WizPageWelcome,
  389. WizPageEula,
  390. WizPagePreparing,
  391. #ifdef PNP_DEBUG_UI
  392. WizPageInstalledHardware,
  393. #endif // PNP_DEBUG_UI
  394. WizPageRegionalSettings,
  395. WizPageNameOrg,
  396. WizPageProductIdCd,
  397. WizPageProductIdOem,
  398. WizPageProductIdSelect,
  399. WizPagePlaceholderLic,
  400. WizPageComputerName,
  401. #ifdef _OCM
  402. WizPageOcManager,
  403. WizPageOcManagerEarly,
  404. #endif
  405. #ifdef DOLOCALUSER
  406. WizPageUserAccount,
  407. #endif
  408. #ifdef _X86_
  409. WizPagePentiumErrata,
  410. #endif
  411. WizPageSteps1,
  412. #ifdef _OCM
  413. WizPageOcManagerPrenet,
  414. #endif
  415. WizSetupPreNet,
  416. WizPagePlaceholderNet,
  417. WizSetupPostNet,
  418. #ifdef _OCM
  419. WizPageOcManagerPostnet,
  420. WizPageOcManagerLate,
  421. WizPageOcManagerSetup,
  422. #endif
  423. WizPageCopyFiles,
  424. WizPageLast
  425. };
  426. UINT AsrWizardPages[] = { WizPagePreparingAsr,
  427. #ifdef PNP_DEBUG_UI
  428. WizPageInstalledHardware,
  429. #endif //PNP_DEBUG_UI
  430. #ifdef _OCM
  431. WizPageOcManager,
  432. WizPageOcManagerEarly,
  433. WizPageOcManagerPrenet,
  434. #endif
  435. WizSetupPreNet,
  436. WizPagePlaceholderNet,
  437. WizSetupPostNet,
  438. #ifdef _OCM
  439. WizPageOcManagerPostnet,
  440. WizPageOcManagerLate,
  441. WizPageOcManagerSetup,
  442. #endif
  443. WizPageAsrLast
  444. };
  445. UINT UpgradeWizardPages[] = { WizPageWelcome,
  446. WizPageEula,
  447. WizPagePreparing,
  448. #ifdef PNP_DEBUG_UI
  449. WizPageInstalledHardware,
  450. #endif // PNP_DEBUG_UI
  451. WizPageRegionalSettings,
  452. WizPageProductIdCd,
  453. WizPageProductIdOem,
  454. WizPageProductIdSelect,
  455. WizPagePlaceholderLic,
  456. #ifdef _OCM
  457. WizPageOcManager,
  458. WizPageOcManagerEarly,
  459. #endif
  460. #ifdef _X86_
  461. WizPagePentiumErrata,
  462. #endif
  463. WizPageSteps1,
  464. #ifdef _OCM
  465. WizPageOcManagerPrenet,
  466. #endif
  467. WizSetupPreNet,
  468. WizPagePlaceholderNet,
  469. WizSetupPostNet,
  470. #ifdef _OCM
  471. WizPageOcManagerPostnet,
  472. WizPageOcManagerLate,
  473. WizPageOcManagerSetup,
  474. #endif
  475. WizPageCopyFiles,
  476. WizPageLast
  477. };
  478. UINT UiTestWizardPages[] = { WizPageWelcome,
  479. WizPageEula,
  480. WizPagePreparing,
  481. #ifdef PNP_DEBUG_UI
  482. WizPageInstalledHardware,
  483. #endif // PNP_DEBUG_UI
  484. WizPageRegionalSettings,
  485. WizPageNameOrg,
  486. WizPageProductIdCd,
  487. WizPageProductIdOem,
  488. WizPageProductIdSelect,
  489. WizPageComputerName,
  490. #ifdef DOLOCALUSER
  491. WizPageUserAccount,
  492. #endif
  493. #ifdef _X86_
  494. WizPagePentiumErrata,
  495. #endif // def _X86_
  496. WizPageSteps1,
  497. WizPageCopyFiles,
  498. WizPageLast
  499. };
  500. UINT MiniSetupWizardPages[] = {
  501. WizPageWelcome,
  502. WizPageEula,
  503. WizPagePreparing,
  504. WizPageRegionalSettings,
  505. WizPageNameOrg,
  506. WizPageProductIdCd,
  507. WizPageProductIdOem,
  508. WizPageProductIdSelect,
  509. WizPagePlaceholderLic,
  510. WizPageComputerName,
  511. #ifdef _OCM
  512. WizPageOcManager,
  513. WizPageOcManagerEarly,
  514. #endif
  515. WizPageSteps1,
  516. #ifdef _OCM
  517. WizPageOcManagerPrenet,
  518. #endif
  519. WizPagePlaceholderNet,
  520. #ifdef _OCM
  521. WizPageOcManagerPostnet,
  522. WizPageOcManagerLate,
  523. WizPageOcManagerSetup,
  524. #endif
  525. WizPageCopyFiles,
  526. WizPageLast
  527. };
  528. #define TIME_INITIALIZE 120
  529. #define TIME_INSTALLSECURITY 30
  530. #define TIME_PRECOMPILEINFS 90 // calc something with #infs and throughput
  531. #define TIME_INSTALLDEVICES 330 // How can we calc a better number?
  532. // Also Pre compile INFs is part of Device Install page
  533. #define TIME_INSTALLENUMDEVICES1 120
  534. #define TIME_INSTALLLEGACYDEVICES 30
  535. #define TIME_INSTALLENUMDEVICES2 60
  536. #define TIME_NETINSTALL 150 // need better number
  537. #define TIME_OCINSTALL 420 // need better number
  538. #define TIME_INSTALLCOMPONENTINFS 240 // need better number
  539. #define TIME_INF_REGISTRATION 300 // need better number
  540. #define TIME_RUNONCE_REGISTRATION 120 // need better number
  541. #define TIME_SECURITYTEMPLATE 150 // need better number
  542. #define TIME_WIN9XMIGRATION 120 // Need better number
  543. #define TIME_SFC 420
  544. #define TIME_SAVEREPAIR 30
  545. #define TIME_REMOVETEMOFILES 30
  546. #define TIME_ALL 2190
  547. //
  548. // The entries in this array need to correcpond to the enum SetupPhases in setuppp.h
  549. SETUPPHASE SetupPhase[] = {
  550. { TIME_INITIALIZE, FALSE }, // Initialize
  551. { TIME_INSTALLSECURITY, FALSE }, // InstallSecurity
  552. { TIME_PRECOMPILEINFS, FALSE }, // PrecompileInfs
  553. { TIME_INSTALLENUMDEVICES1, FALSE }, // InstallDevices
  554. { TIME_INSTALLLEGACYDEVICES, FALSE },
  555. { TIME_INSTALLENUMDEVICES2, FALSE },
  556. { TIME_NETINSTALL, FALSE }, // NetInstall
  557. { TIME_OCINSTALL, FALSE }, // OCInstall
  558. { TIME_INSTALLCOMPONENTINFS, FALSE},
  559. { TIME_INF_REGISTRATION, FALSE},
  560. { TIME_RUNONCE_REGISTRATION, FALSE }, // Registration
  561. { TIME_SECURITYTEMPLATE, FALSE }, // SecurityTempates
  562. { TIME_WIN9XMIGRATION, TRUE }, // Win9xMigration
  563. { TIME_SFC, FALSE }, // SFC
  564. { TIME_SAVEREPAIR, FALSE }, // SaveRepair
  565. { TIME_REMOVETEMOFILES, FALSE } // RemoveTempFiles
  566. };
  567. UINT CurrentPhase = Phase_Unknown;
  568. ULONG RemainingTime = 0;
  569. #ifdef _OCM
  570. BOOL
  571. pOcManagerPages(
  572. IN PSETUP_REQUEST_PAGES Page,
  573. OUT HPROPSHEETPAGE *WizardPageHandles,
  574. IN OUT UINT *PageCount
  575. );
  576. #endif
  577. BOOL
  578. GetNetworkWizardPages(
  579. OUT HPROPSHEETPAGE *PageHandles,
  580. IN OUT PUINT PageCount
  581. )
  582. /*++
  583. Routine Description:
  584. This routine asks net setup for its wizard pages and passes it
  585. a pointer to a global structure to be used later to pass info
  586. back and forth between base and net setups. Net setup must not
  587. attempt to use any fields in there yet because they are not
  588. filled in yet.
  589. Arguments:
  590. PropSheetHandles - receives network setup wizard page handles.
  591. PageCount - on input, supplies number of slots in PropSheetHandles
  592. array. On output, receives number of handles actually placed
  593. in the array.
  594. Return Value:
  595. If the netsetup wizard dll could not be loaded, returns FALSE.
  596. Otherwise returns TRUE if no error, or does not return if error.
  597. --*/
  598. {
  599. NETSETUPPAGEREQUESTPROC PageRequestProc;
  600. HMODULE NetSetupModule;
  601. DWORD d;
  602. BOOL b;
  603. b = FALSE;
  604. d = NO_ERROR;
  605. NetSetupModule = LoadLibrary(L"NETSHELL");
  606. if(!NetSetupModule) {
  607. //
  608. // If the network wizard isn't around, then the legacy network inf
  609. // had better be.
  610. //
  611. WCHAR x[MAX_PATH];
  612. GetSystemDirectory(x,MAX_PATH);
  613. pSetupConcatenatePaths(x,L"NTLANMAN.INF",MAX_PATH,NULL);
  614. if(FileExists(x,NULL)) {
  615. return(FALSE);
  616. }
  617. d = ERROR_FILE_NOT_FOUND;
  618. goto c0;
  619. }
  620. PageRequestProc = (NETSETUPPAGEREQUESTPROC)GetProcAddress(
  621. NetSetupModule,
  622. NETSETUPPAGEREQUESTPROCNAME
  623. );
  624. if(!PageRequestProc) {
  625. d = GetLastError();
  626. goto c0;
  627. }
  628. //
  629. // Net setup needs product type really early.
  630. //
  631. SetProductTypeInRegistry();
  632. //
  633. // Call net setup to get its pages.
  634. //
  635. InternalSetupData.dwSizeOf = sizeof(INTERNAL_SETUP_DATA);
  636. b = PageRequestProc(PageHandles,PageCount,&InternalSetupData);
  637. //
  638. // If we get here, d is NO_ERROR. If b is FALSE this NO_ERROR will be
  639. // a special case to mean "the network wizard request failed."
  640. // In other error cases, d will have a non-0 value.
  641. //
  642. c0:
  643. if(!b) {
  644. //
  645. // This is fatal, something is really wrong.
  646. //
  647. FatalError(MSG_LOG_NETWIZPAGE,d,0,0);
  648. }
  649. return(TRUE);
  650. }
  651. BOOL
  652. GetLicenseWizardPages(
  653. OUT HPROPSHEETPAGE *PageHandles,
  654. IN OUT PUINT PageCount
  655. )
  656. /*++
  657. Routine Description:
  658. This routine asks liccpa setup for its wizard pages and passes it
  659. a pointer to a global structure to be used later to pass info
  660. back and forth between base and liccpa setups. Liccpa setup must not
  661. attempt to use any fields in there yet because they are not
  662. filled in yet.
  663. Arguments:
  664. PropSheetHandles - receives liccpa setup wizard page handles.
  665. PageCount - on input, supplies number of slots in PropSheetHandles
  666. array. On output, receives number of handles actually placed
  667. in the array.
  668. Return Value:
  669. If the liccpa dll could not be loaded, returns FALSE.
  670. Otherwise returns TRUE if no error, or does not return if error.
  671. --*/
  672. {
  673. NETSETUPPAGEREQUESTPROC PageRequestProc;
  674. HMODULE LicenseSetupModule;
  675. DWORD d;
  676. BOOL b;
  677. b = FALSE;
  678. d = NO_ERROR;
  679. LicenseSetupModule = LoadLibrary(L"LICCPA.CPL");
  680. if(!LicenseSetupModule) {
  681. //
  682. // If the license wizard isn't around, then this is a fatal error
  683. //
  684. d = ERROR_FILE_NOT_FOUND;
  685. goto c0;
  686. }
  687. PageRequestProc = (NETSETUPPAGEREQUESTPROC)GetProcAddress(
  688. LicenseSetupModule,
  689. LICENSESETUPPAGEREQUESTPROCNAME
  690. );
  691. if(!PageRequestProc) {
  692. d = GetLastError();
  693. goto c0;
  694. }
  695. // //
  696. // // Net setup needs product type really early.
  697. // //
  698. // SetProductTypeInRegistry();
  699. //
  700. // Call liccpa setup to get its pages.
  701. //
  702. InternalSetupData.dwSizeOf = sizeof(INTERNAL_SETUP_DATA);
  703. b = PageRequestProc(PageHandles,PageCount,&InternalSetupData);
  704. //
  705. // If we get here, d is NO_ERROR. If b is FALSE this NO_ERROR will be
  706. // a special case to mean "the license wizard request failed."
  707. // In other error cases, d will have a non-0 value.
  708. //
  709. c0:
  710. if(!b) {
  711. //
  712. // This is fatal, something is really wrong.
  713. //
  714. FatalError(MSG_LOG_LICWIZPAGE,d,0,0);
  715. }
  716. return(TRUE);
  717. }
  718. VOID
  719. SetWizardButtons(
  720. IN HWND hdlgPage,
  721. IN WizPage PageNumber
  722. )
  723. {
  724. //
  725. // Dirty hack to hide cancel and help buttons.
  726. // We don't have any help buttons but some of the other
  727. // components whose pages are included here might; we want to make
  728. // sure that for us, the help button stays removed!
  729. //
  730. EnableWindow(GetDlgItem(GetParent(hdlgPage),IDCANCEL),FALSE);
  731. ShowWindow(GetDlgItem(GetParent(hdlgPage),IDCANCEL),SW_HIDE);
  732. EnableWindow(GetDlgItem(GetParent(hdlgPage),IDHELP),FALSE);
  733. ShowWindow(GetDlgItem(GetParent(hdlgPage),IDHELP),SW_HIDE);
  734. PropSheet_SetWizButtons(GetParent(hdlgPage),SetupWizardPages[PageNumber].ButtonState);
  735. SetWindowLongPtr(hdlgPage,DWLP_MSGRESULT,0);
  736. }
  737. VOID
  738. WizardBringUpHelp(
  739. IN HWND hdlg,
  740. IN WizPage PageNumber
  741. )
  742. {
  743. #if 0
  744. BOOL b;
  745. b = WinHelp(
  746. hdlg,
  747. L"setupnt.hlp",
  748. HELP_CONTEXT,
  749. SetupWizardPages[PageNumber].HelpContextId
  750. );
  751. if(!b) {
  752. MessageBoxFromMessage(
  753. hdlg,
  754. MSG_CANT_INVOKE_WINHELP,
  755. NULL,
  756. IDS_ERROR,
  757. MB_ICONSTOP | MB_OK
  758. );
  759. }
  760. #else
  761. UNREFERENCED_PARAMETER(hdlg);
  762. UNREFERENCED_PARAMETER(PageNumber);
  763. #endif
  764. }
  765. VOID
  766. WizardKillHelp(
  767. IN HWND hdlg
  768. )
  769. {
  770. #if 0
  771. WinHelp(hdlg,NULL,HELP_QUIT,0);
  772. #else
  773. UNREFERENCED_PARAMETER(hdlg);
  774. #endif
  775. }
  776. WNDPROC OldWizDlgProc;
  777. INT_PTR
  778. NewWizDlgProc(
  779. IN HWND hdlg,
  780. IN UINT msg,
  781. IN WPARAM wParam,
  782. IN LPARAM lParam
  783. )
  784. {
  785. static RECT rect;
  786. static BOOL Visible = TRUE;
  787. BOOL b = FALSE;
  788. //
  789. // Eat WM_SYSCOMMAND where wParam is SC_CLOSE.
  790. // Pass all other messages on.
  791. //
  792. if((msg != WM_SYSCOMMAND) || ((wParam & 0xfff0) != SC_CLOSE))
  793. {
  794. switch (msg)
  795. {
  796. // Set the progress text
  797. // Indicates what setup is doing.
  798. case WMX_SETPROGRESSTEXT:
  799. BB_SetProgressText((PCTSTR)lParam);
  800. b = TRUE;
  801. break;
  802. case WMX_BB_SETINFOTEXT:
  803. BB_SetInfoText((PTSTR)lParam);
  804. b = TRUE;
  805. break;
  806. // Enabled, disable, show, hide the progress gauge on the billboard
  807. // wParam should be SW_SHOW or SW_HIDE
  808. case WMX_BBPROGRESSGAUGE:
  809. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,BB_ShowProgressGaugeWnd((UINT)wParam));
  810. b= TRUE;
  811. break;
  812. // Start, stop the billboard text.
  813. // This start, stops the billboard text and shows, hides the wizard pages
  814. case WMX_BBTEXT:
  815. if (hinstBB)
  816. {
  817. if (wParam != 0)
  818. {
  819. if (Visible)
  820. {
  821. // Get the current position of the wizard
  822. // We restore this position when we need to show it.
  823. GetWindowRect(hdlg, &rect);
  824. SetWindowPos(hdlg,
  825. GetBBhwnd(),
  826. 0,0,0,0,
  827. SWP_NOZORDER);
  828. SetActiveWindow(GetBBhwnd());
  829. Visible = FALSE;
  830. }
  831. }
  832. else
  833. {
  834. if (!Visible)
  835. {
  836. SetWindowPos(hdlg,
  837. HWND_TOP,
  838. rect.left,
  839. rect.top,
  840. rect.right-rect.left,
  841. rect.bottom-rect.top,
  842. SWP_SHOWWINDOW);
  843. }
  844. Visible = TRUE;
  845. }
  846. if (!StartStopBB((wParam != 0)))
  847. {
  848. if (!Visible)
  849. {
  850. SetWindowPos(hdlg,
  851. HWND_TOP,
  852. rect.left,
  853. rect.top,
  854. rect.right-rect.left,
  855. rect.bottom-rect.top,
  856. SWP_SHOWWINDOW);
  857. }
  858. Visible = TRUE;
  859. }
  860. }
  861. else
  862. {
  863. if (!Visible)
  864. {
  865. SetWindowPos(hdlg,
  866. HWND_TOP,
  867. rect.left,
  868. rect.top,
  869. rect.right-rect.left,
  870. rect.bottom-rect.top,
  871. SWP_SHOWWINDOW);
  872. }
  873. Visible = TRUE;
  874. }
  875. return TRUE;
  876. /*
  877. case WMX_BBTEXT:
  878. if (hinstBB)
  879. {
  880. if (wParam != 0)
  881. {
  882. ShowWindow (hdlg, SW_HIDE);
  883. }
  884. else
  885. {
  886. ShowWindow (hdlg, SW_SHOW);
  887. }
  888. if (!StartStopBB((wParam != 0)))
  889. {
  890. ShowWindow (hdlg, SW_SHOW);
  891. }
  892. }
  893. else
  894. {
  895. ShowWindow (hdlg, SW_SHOW);
  896. }
  897. b = TRUE;
  898. break;
  899. */
  900. default:
  901. b = (BOOL)CallWindowProc(OldWizDlgProc,hdlg,msg,wParam,lParam);
  902. break;
  903. }
  904. }
  905. return b;
  906. }
  907. #ifdef _OCM
  908. //
  909. // Bogus global variable necessary because there's no way to get
  910. // a value through to the PropSheetCallback.
  911. //
  912. PVOID _CBx;
  913. #endif
  914. int
  915. CALLBACK
  916. WizardCallback(
  917. IN HWND hdlg,
  918. IN UINT code,
  919. IN LPARAM lParam
  920. )
  921. {
  922. DLGTEMPLATE *DlgTemplate;
  923. HMENU menu;
  924. UNREFERENCED_PARAMETER(hdlg);
  925. //
  926. // Get rid of context sensitive help control on title bar
  927. //
  928. if(code == PSCB_PRECREATE) {
  929. DlgTemplate = (DLGTEMPLATE *)lParam;
  930. DlgTemplate->style &= ~DS_CONTEXTHELP;
  931. } else {
  932. if(code == PSCB_INITIALIZED) {
  933. //
  934. // Get rid of close item on system menu.
  935. // Also need to process WM_SYSCOMMAND to eliminate use
  936. // of Alt+F4.
  937. //
  938. if(menu = GetSystemMenu(hdlg,FALSE)) {
  939. EnableMenuItem(menu,SC_CLOSE,MF_BYCOMMAND|MF_GRAYED);
  940. }
  941. OldWizDlgProc = (WNDPROC)SetWindowLongPtr(hdlg,DWLP_DLGPROC,(LONG_PTR)NewWizDlgProc);
  942. #ifdef _OCM
  943. // inform ocm components of the wizard dialog handle
  944. if (_CBx)
  945. OcRememberWizardDialogHandle(_CBx,hdlg);
  946. #endif
  947. }
  948. }
  949. return(0);
  950. }
  951. VOID
  952. Wizard(
  953. #ifdef _OCM
  954. IN PVOID OcManagerContext
  955. #else
  956. VOID
  957. #endif
  958. )
  959. {
  960. PROPSHEETHEADER psh;
  961. PUINT PageList;
  962. UINT PagesInSet;
  963. UINT i;
  964. UINT PageOrdinal;
  965. UINT PageCount;
  966. UINT NetPageCount;
  967. UINT LicPageCount;
  968. #ifdef _OCM
  969. HPROPSHEETPAGE WizardPageHandles[MAXPROPPAGES];
  970. #else
  971. HPROPSHEETPAGE WizardPageHandles[WizPageMaximum+MAX_NETWIZ_PAGES+MAX_LICWIZ_PAGES];
  972. #endif
  973. BOOL b;
  974. INT_PTR Status;
  975. HDC hdc;
  976. WCHAR Text[500];
  977. #ifdef _OCM
  978. PSETUP_REQUEST_PAGES PagesFromOcManager[WizPagesTypeMax];
  979. OC_PAGE_CONTROLS OcPageControls,OcDetailsControls;
  980. SETUP_PAGE_CONTROLS OcSetupPageControls;
  981. #endif
  982. //
  983. // Determine which set of pages to use and how many there are in the set.
  984. //
  985. if(UiTest) {
  986. PageList = UiTestWizardPages;
  987. PagesInSet = sizeof(UiTestWizardPages)/sizeof(UiTestWizardPages[0]);
  988. } else {
  989. if(Upgrade) {
  990. PageList = UpgradeWizardPages;
  991. PagesInSet = sizeof(UpgradeWizardPages)/sizeof(UpgradeWizardPages[0]);
  992. } else {
  993. if( MiniSetup ) {
  994. PageList = MiniSetupWizardPages;
  995. PagesInSet = sizeof(MiniSetupWizardPages)/sizeof(MiniSetupWizardPages[0]);
  996. }
  997. else {
  998. if( AsrIsEnabled() ) {
  999. PageList = AsrWizardPages;
  1000. PagesInSet = sizeof(AsrWizardPages)/sizeof(AsrWizardPages[0]);
  1001. } else {
  1002. PageList = InitialWizardPages;
  1003. PagesInSet = sizeof(InitialWizardPages)/sizeof(InitialWizardPages[0]);
  1004. }
  1005. }
  1006. }
  1007. }
  1008. #ifdef _OCM
  1009. // for callbacks
  1010. _CBx = OcManagerContext;
  1011. // Get pages from OC Manager components.
  1012. if(OcManagerContext) {
  1013. Status = OcGetWizardPages(OcManagerContext,PagesFromOcManager);
  1014. if(Status != NO_ERROR) {
  1015. FatalError(MSG_LOG_WIZPAGES,0,0);
  1016. }
  1017. } else {
  1018. ZeroMemory(PagesFromOcManager,sizeof(PagesFromOcManager));
  1019. }
  1020. #endif
  1021. //
  1022. // Create each page. Some of the pages are placeholders for external pages,
  1023. // which are handled specially.
  1024. //
  1025. b = TRUE;
  1026. PageCount = 0;
  1027. for(i=0; b && (i<PagesInSet); i++) {
  1028. switch(PageOrdinal = PageList[i]) {
  1029. case WizPagePlaceholderNet:
  1030. //
  1031. // Fetch network pages.
  1032. //
  1033. NetPageCount = MAX_NETWIZ_PAGES;
  1034. if(GetNetworkWizardPages(&WizardPageHandles[PageCount],&NetPageCount)) {
  1035. PageCount += NetPageCount;
  1036. NetWizard = TRUE;
  1037. }
  1038. break;
  1039. case WizPagePlaceholderLic:
  1040. if( (ProductType != PRODUCT_WORKSTATION) ) {
  1041. //
  1042. // Fetch license pages.
  1043. //
  1044. LicPageCount = MAX_LICWIZ_PAGES;
  1045. if(GetLicenseWizardPages(&WizardPageHandles[PageCount],&LicPageCount)) {
  1046. PageCount += LicPageCount;
  1047. }
  1048. }
  1049. break;
  1050. case WizPagePreparing:
  1051. //
  1052. // We let the PnP engine run out of process
  1053. // and asynchronously for a MiniSetup case.
  1054. //
  1055. //
  1056. // If we're doing a mini Setup, then we ONLY do
  1057. // the preparing page if the user has asked us to
  1058. // do pnp enumeration.
  1059. //
  1060. if( MiniSetup && (PnPReEnumeration == FALSE)) {
  1061. break;
  1062. }
  1063. goto dodefault;
  1064. break;
  1065. case WizPageCopyFiles:
  1066. #ifdef _X86_
  1067. if (Win95Upgrade) {
  1068. SetupWizardPages[PageOrdinal].Page.pszTemplate = MAKEINTRESOURCE(IDD_COPYFILES4);
  1069. }
  1070. #endif
  1071. #ifdef _OCM
  1072. MYASSERT(OcManagerContext);
  1073. SetupWizardPages[PageOrdinal].Page.lParam = (LPARAM) OcManagerContext;
  1074. #endif
  1075. goto dodefault;
  1076. break;
  1077. #ifdef _OCM
  1078. case WizPageWelcome:
  1079. //
  1080. // If there's a welcome page from an OC Manager component
  1081. // then use it. Otherwise use the standard setup one.
  1082. //
  1083. if(!pOcManagerPages(PagesFromOcManager[WizPagesWelcome],WizardPageHandles,&PageCount)) {
  1084. goto dodefault;
  1085. }
  1086. break;
  1087. case WizPageLast:
  1088. //
  1089. // If there's a final page from an OC Manager component
  1090. // then use it. Otherwise use the standard setup one.
  1091. //
  1092. if(!pOcManagerPages(PagesFromOcManager[WizPagesFinal],WizardPageHandles,&PageCount)) {
  1093. goto dodefault;
  1094. }
  1095. break;
  1096. case WizPageOcManagerEarly:
  1097. pOcManagerPages(PagesFromOcManager[WizPagesEarly],WizardPageHandles,&PageCount);
  1098. break;
  1099. case WizPageOcManagerPrenet:
  1100. pOcManagerPages(PagesFromOcManager[WizPagesPrenet],WizardPageHandles,&PageCount);
  1101. break;
  1102. case WizPageOcManagerPostnet:
  1103. pOcManagerPages(PagesFromOcManager[WizPagesPostnet],WizardPageHandles,&PageCount);
  1104. break;
  1105. case WizPageOcManagerLate:
  1106. pOcManagerPages(PagesFromOcManager[WizPagesLate],WizardPageHandles,&PageCount);
  1107. break;
  1108. case WizPageOcManager:
  1109. if(OcManagerContext && OcSubComponentsPresent(OcManagerContext)) {
  1110. OcPageControls.TemplateModule = MyModuleHandle;
  1111. OcPageControls.TemplateResource = MAKEINTRESOURCE(IDD_OCM_WIZARD_PAGE);
  1112. OcPageControls.ListBox = IDC_LISTBOX;
  1113. OcPageControls.TipText = IDT_TIP;
  1114. OcPageControls.DetailsButton = IDB_DETAILS;
  1115. OcPageControls.ResetButton = 0; // unused
  1116. OcPageControls.InstalledCountText = 0; // unused
  1117. OcPageControls.SpaceNeededText = IDT_SPACE_NEEDED_NUM;
  1118. OcPageControls.SpaceAvailableText = IDT_SPACE_AVAIL_NUM;
  1119. OcPageControls.InstructionsText = IDT_INSTRUCTIONS;
  1120. OcPageControls.HeaderText = IDS_OCPAGE_HEADER;
  1121. OcPageControls.SubheaderText = IDS_OCPAGE_SUBHEAD;
  1122. OcPageControls.ComponentHeaderText = IDT_COMP_TITLE;
  1123. OcDetailsControls = OcPageControls;
  1124. OcDetailsControls.TemplateResource = MAKEINTRESOURCE(IDD_OCM_DETAILS);
  1125. WizardPageHandles[PageCount] = OcCreateOcPage(
  1126. OcManagerContext,
  1127. &OcPageControls,
  1128. &OcDetailsControls
  1129. );
  1130. if(WizardPageHandles[PageCount]) {
  1131. PageCount++;
  1132. } else {
  1133. b = FALSE;
  1134. }
  1135. }
  1136. break;
  1137. case WizPageOcManagerSetup:
  1138. if(OcManagerContext) {
  1139. OcSetupPageControls.TemplateModule = MyModuleHandle;
  1140. OcSetupPageControls.TemplateResource = MAKEINTRESOURCE(IDD_OCM_PROGRESS_PAGE);
  1141. OcSetupPageControls.ProgressBar = IDC_PROGRESS;
  1142. OcSetupPageControls.ProgressLabel = IDT_THERM_LABEL;
  1143. OcSetupPageControls.ProgressText = IDT_TIP;
  1144. OcSetupPageControls.AnimationControl = IDA_EXTERNAL_PROGRAM;
  1145. OcSetupPageControls.AnimationResource = IDA_FILECOPY;
  1146. OcSetupPageControls.ForceExternalProgressIndicator = FALSE;
  1147. OcSetupPageControls.AllowCancel = FALSE;
  1148. OcSetupPageControls.HeaderText = IDS_PROGPAGE_HEADER;
  1149. OcSetupPageControls.SubheaderText = IDS_PROGPAGE_SUBHEAD;
  1150. if(WizardPageHandles[PageCount] = OcCreateSetupPage(OcManagerContext,&OcSetupPageControls)) {
  1151. PageCount++;
  1152. } else {
  1153. b = FALSE;
  1154. }
  1155. }
  1156. break;
  1157. #endif
  1158. case WizPageComputerName:
  1159. if( GetProductFlavor() == 4)
  1160. {
  1161. // If Personal use a different template
  1162. SetupWizardPages[PageOrdinal].Page.pszTemplate = MAKEINTRESOURCE(IDD_COMPUTERNAME2);
  1163. }
  1164. goto dodefault;
  1165. break;
  1166. default:
  1167. dodefault:
  1168. {
  1169. UINT uiStrID;
  1170. SetupWizardPages[PageOrdinal].Page.hInstance = MyModuleHandle;
  1171. SetupWizardPages[PageOrdinal].Page.pszTitle = (PWSTR)UIntToPtr( SetupTitleStringId );
  1172. SetupWizardPages[PageOrdinal].Page.dwFlags |= PSP_USETITLE;
  1173. //
  1174. // Convert resource ids to actual strings for header title and subtitle,
  1175. // if required for this page.
  1176. //
  1177. if(SetupWizardPages[PageOrdinal].Page.dwFlags & PSP_USEHEADERTITLE) {
  1178. uiStrID = (UINT)((ULONG_PTR)SetupWizardPages[PageOrdinal].Page.pszHeaderTitle);
  1179. if ((PageOrdinal == WizPageComputerName) &&
  1180. (GetProductFlavor() == 4))
  1181. {
  1182. uiStrID = IDS_COMPUTERNAME2;
  1183. }
  1184. SetupWizardPages[PageOrdinal].Page.pszHeaderTitle = MyLoadString(uiStrID
  1185. //(UINT)((ULONG_PTR)SetupWizardPages[PageOrdinal].Page.pszHeaderTitle)
  1186. );
  1187. if(!SetupWizardPages[PageOrdinal].Page.pszHeaderTitle) {
  1188. SetupWizardPages[PageOrdinal].Page.dwFlags &= ~PSP_USEHEADERTITLE;
  1189. }
  1190. }
  1191. if(SetupWizardPages[PageOrdinal].Page.dwFlags & PSP_USEHEADERSUBTITLE) {
  1192. uiStrID = (UINT)((ULONG_PTR)SetupWizardPages[PageOrdinal].Page.pszHeaderSubTitle);
  1193. if ((PageOrdinal == WizPageComputerName) &&
  1194. (GetProductFlavor() == 4))
  1195. {
  1196. uiStrID = IDS_COMPUTERNAME2_SUB;
  1197. }
  1198. SetupWizardPages[PageOrdinal].Page.pszHeaderSubTitle = MyLoadString(uiStrID
  1199. //(UINT)((ULONG_PTR)SetupWizardPages[PageOrdinal].Page.pszHeaderSubTitle)
  1200. );
  1201. if(!SetupWizardPages[PageOrdinal].Page.pszHeaderSubTitle) {
  1202. SetupWizardPages[PageOrdinal].Page.dwFlags &= ~PSP_USEHEADERSUBTITLE;
  1203. }
  1204. }
  1205. WizardPageHandles[PageCount] = CreatePropertySheetPage(
  1206. &SetupWizardPages[PageOrdinal].Page
  1207. );
  1208. if(WizardPageHandles[PageCount]) {
  1209. PageCount++;
  1210. } else {
  1211. b = FALSE;
  1212. }
  1213. }
  1214. break;
  1215. }
  1216. }
  1217. if(b) {
  1218. psh.dwSize = sizeof(PROPSHEETHEADER);
  1219. psh.dwFlags = PSH_WIZARD | PSH_USECALLBACK | PSH_WIZARD97 |
  1220. PSH_HEADER;
  1221. // in order to have the watermark sized correctly for all languages,
  1222. // we must draw the bitmap ourselves rather than letting wiz97
  1223. // take care of it for us.
  1224. //PSH_WATERMARK | PSH_HEADER;
  1225. psh.hwndParent = MainWindowHandle;
  1226. psh.hInstance = MyModuleHandle;
  1227. psh.pszCaption = NULL;
  1228. psh.nPages = PageCount;
  1229. psh.nStartPage = 0;
  1230. psh.phpage = WizardPageHandles;
  1231. psh.pfnCallback = WizardCallback;
  1232. //psh.pszbmWatermark = MAKEINTRESOURCE(IDB_BITMAP1);
  1233. psh.pszbmHeader = MAKEINTRESOURCE(IDB_HEADER);
  1234. Status = PropertySheet(&psh);
  1235. if (Status == -1) {
  1236. FatalError(MSG_LOG_WIZPAGES,0,0);
  1237. }
  1238. } else {
  1239. FatalError(MSG_LOG_WIZPAGES,0,0);
  1240. }
  1241. for (i = 0; i < WizPagesTypeMax ; i++) {
  1242. MyFree(PagesFromOcManager[i]);
  1243. }
  1244. return;
  1245. }
  1246. #ifdef _OCM
  1247. BOOL
  1248. pOcManagerPages(
  1249. IN PSETUP_REQUEST_PAGES Page,
  1250. OUT HPROPSHEETPAGE *WizardPageHandles,
  1251. IN OUT UINT *PageCount
  1252. )
  1253. {
  1254. BOOL b;
  1255. if(Page && Page->MaxPages) {
  1256. CopyMemory(
  1257. &WizardPageHandles[*PageCount],
  1258. Page->Pages,
  1259. Page->MaxPages * sizeof(HPROPSHEETPAGE)
  1260. );
  1261. *PageCount += Page->MaxPages;
  1262. b = TRUE;
  1263. } else {
  1264. b = FALSE;
  1265. }
  1266. return(b);
  1267. }
  1268. #endif
  1269. VOID
  1270. WizardUiTest(
  1271. VOID
  1272. )
  1273. {
  1274. WCHAR path[MAX_PATH];
  1275. UiTest = TRUE;
  1276. SyssetupInf = SetupOpenInfFile(L"syssetup.inf",NULL,INF_STYLE_WIN4,NULL);
  1277. lstrcpy(SourcePath,L"D:\\$WIN_NT$.LS");
  1278. #ifdef _OCM
  1279. {
  1280. PVOID OcManagerContext = FireUpOcManager();
  1281. Wizard(OcManagerContext);
  1282. KillOcManager(OcManagerContext);
  1283. }
  1284. #else
  1285. Wizard();
  1286. #endif
  1287. SetupCloseInfFile(SyssetupInf);
  1288. }
  1289. DWORD GetPhase_InitializeEstimate ()
  1290. {
  1291. return TIME_INITIALIZE;
  1292. }
  1293. DWORD GetPhase_InstallSecurityEstimate ()
  1294. {
  1295. return TIME_INSTALLSECURITY;
  1296. }
  1297. DWORD GetPhase_PrecompileInfsEstimate ()
  1298. {
  1299. return TIME_PRECOMPILEINFS;
  1300. }
  1301. DWORD GetPhase_InstallDevicesEstimate ()
  1302. {
  1303. return TIME_INSTALLDEVICES;
  1304. }
  1305. DWORD GetPhase_InstallEnumDevices1Estimate ()
  1306. {
  1307. return TIME_INSTALLENUMDEVICES1;
  1308. }
  1309. DWORD GetPhase_InstallLegacyDevicesEstimate ()
  1310. {
  1311. return TIME_INSTALLLEGACYDEVICES;
  1312. }
  1313. DWORD GetPhase_InstallEnumDevices2Estimate ()
  1314. {
  1315. return TIME_INSTALLENUMDEVICES2;
  1316. }
  1317. DWORD GetPhase_NetInstallEstimate ()
  1318. {
  1319. return TIME_NETINSTALL;
  1320. }
  1321. DWORD GetPhase_OCInstallEstimate ()
  1322. {
  1323. return TIME_OCINSTALL;
  1324. }
  1325. DWORD GetPhase_InstallComponentInfsEstimate ()
  1326. {
  1327. return TIME_INSTALLCOMPONENTINFS;
  1328. }
  1329. DWORD GetPhase_Inf_RegistrationEstimate ()
  1330. {
  1331. return TIME_INF_REGISTRATION;
  1332. }
  1333. DWORD GetPhase_RunOnce_RegistrationEstimate ()
  1334. {
  1335. return TIME_RUNONCE_REGISTRATION;
  1336. }
  1337. DWORD GetPhase_SecurityTempatesEstimate ()
  1338. {
  1339. return TIME_SECURITYTEMPLATE;
  1340. }
  1341. LPTSTR WinRegisteries[] = { TEXT("system.dat"),
  1342. TEXT("User.dat"),
  1343. TEXT("classes.dat"),
  1344. TEXT("")};
  1345. DWORD GetPhase_Win9xMigrationEstimate ()
  1346. {
  1347. // Get the size of the registery,
  1348. // system.dat, user.dat and classes.dat(only exiss on Millennium)
  1349. // If the size if above 3MB, do the following
  1350. // Substract 3MB, devide by 9000 (that should give use the through put), and add 100 seconds
  1351. DWORD dwTime = TIME_WIN9XMIGRATION;
  1352. DWORD dwSize = 0;
  1353. TCHAR szRegPath[MAX_PATH];
  1354. TCHAR szRegName[MAX_PATH];
  1355. LPTSTR pRegName = NULL;
  1356. UINT index = 0;
  1357. HANDLE hFind;
  1358. WIN32_FIND_DATA FindData;
  1359. SetupDebugPrint(L"SETUP: Calculating registery size");
  1360. if (GetWindowsDirectory(szRegPath, MAX_PATH))
  1361. {
  1362. pSetupConcatenatePaths (szRegPath, L"Setup\\DefHives", MAX_PATH, NULL);
  1363. while (*WinRegisteries[index])
  1364. {
  1365. lstrcpy(szRegName, szRegPath);
  1366. pSetupConcatenatePaths ( szRegName, WinRegisteries[index], MAX_PATH, NULL);
  1367. hFind = FindFirstFile(szRegName, &FindData);
  1368. if (hFind != INVALID_HANDLE_VALUE)
  1369. {
  1370. SetupDebugPrint2(L"SETUP: %s size is: %2ld",
  1371. szRegName,
  1372. FindData.nFileSizeLow
  1373. );
  1374. // Don't worry about the nFileSizeHigh,
  1375. // if that is used the registery is over 4GB
  1376. dwSize += FindData.nFileSizeLow;
  1377. FindClose(hFind);
  1378. }
  1379. index++;
  1380. }
  1381. // Anything below 3.000.000 byte is already in the base time
  1382. if (dwSize > 3000000)
  1383. {
  1384. dwSize -= 3000000;
  1385. // Estimated that for about 9000 bytes we need 1 second.
  1386. dwTime += (dwSize/9000);
  1387. }
  1388. SetupDebugPrint1(L"SETUP: Calculated time for Win9x migration = %1ld seconds", dwTime);
  1389. }
  1390. return dwTime;
  1391. }
  1392. DWORD GetPhase_SFCEstimate ()
  1393. {
  1394. return TIME_SFC;
  1395. }
  1396. DWORD GetPhase_SaveRepairEstimate ()
  1397. {
  1398. return TIME_SAVEREPAIR;
  1399. }
  1400. DWORD GetPhase_RemoveTempFilesEstimate ()
  1401. {
  1402. return TIME_REMOVETEMOFILES;
  1403. }
  1404. void SetTimeEstimates()
  1405. {
  1406. SetupPhase[Phase_Initialize].Time = GetPhase_InitializeEstimate();
  1407. SetupPhase[Phase_InstallSecurity].Time = GetPhase_InstallSecurityEstimate();
  1408. SetupPhase[Phase_PrecompileInfs].Time = GetPhase_PrecompileInfsEstimate();
  1409. SetupPhase[Phase_InstallEnumDevices1].Time = GetPhase_InstallEnumDevices1Estimate();
  1410. SetupPhase[Phase_InstallLegacyDevices].Time = GetPhase_InstallLegacyDevicesEstimate();
  1411. SetupPhase[Phase_InstallEnumDevices2].Time = GetPhase_InstallEnumDevices2Estimate();
  1412. SetupPhase[Phase_OCInstall].Time = GetPhase_OCInstallEstimate();
  1413. SetupPhase[Phase_InstallComponentInfs].Time = GetPhase_InstallComponentInfsEstimate();
  1414. SetupPhase[Phase_Inf_Registration].Time = GetPhase_Inf_RegistrationEstimate();
  1415. SetupPhase[Phase_RunOnce_Registration].Time = GetPhase_RunOnce_RegistrationEstimate();
  1416. SetupPhase[Phase_SecurityTempates].Time = GetPhase_SecurityTempatesEstimate();
  1417. SetupPhase[Phase_Win9xMigration].Time = GetPhase_Win9xMigrationEstimate();
  1418. SetupPhase[Phase_SFC].Time = GetPhase_SFCEstimate();
  1419. SetupPhase[Phase_SaveRepair].Time = GetPhase_SaveRepairEstimate();
  1420. SetupPhase[Phase_RemoveTempFiles].Time = GetPhase_RemoveTempFilesEstimate();
  1421. }
  1422. // Returns the time remaining starting with the current "Phase"
  1423. DWORD CalcTimeRemaining(UINT Phase)
  1424. {
  1425. UINT i;
  1426. DWORD Time = 0;
  1427. CurrentPhase = Phase;
  1428. for (i = Phase; i < Phase_Reboot; i++)
  1429. {
  1430. // Is this a phase we always run or only when upgrading Win9x?
  1431. if (!SetupPhase[i].Win9xUpgradeOnly)
  1432. {
  1433. Time += SetupPhase[i].Time;
  1434. }
  1435. else if (Win95Upgrade)
  1436. {
  1437. Time += SetupPhase[i].Time;
  1438. }
  1439. }
  1440. return Time;
  1441. }
  1442. void SetRemainingTime(DWORD TimeInSeconds)
  1443. {
  1444. DWORD Minutes;
  1445. TCHAR MinuteString[MAX_PATH];
  1446. TCHAR TimeLeft[MAX_PATH];
  1447. Minutes = ((TimeInSeconds)/60) +1;
  1448. if (Minutes > 1)
  1449. {
  1450. if(!LoadString(MyModuleHandle,IDS_TIMEESTIMATE_MINUTES,MinuteString, MAX_PATH))
  1451. {
  1452. lstrcpy(MinuteString,TEXT("Installation will complete in %d minutes or less."));
  1453. }
  1454. wsprintf(TimeLeft, MinuteString, Minutes);
  1455. }
  1456. else
  1457. {
  1458. if(!LoadString(MyModuleHandle,IDS_TIMEESTIMATE_LESSTHENONEMINUTE,TimeLeft, MAX_PATH))
  1459. {
  1460. lstrcpy(TimeLeft,TEXT("Installation will complete in less then 1 minute."));
  1461. }
  1462. }
  1463. BB_SetTimeEstimateText(TimeLeft);
  1464. }