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.

966 lines
32 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. wizard.c
  5. Abstract:
  6. This file implements the setup wizard code for the
  7. FAX server setup.
  8. Environment:
  9. WIN32 User Mode
  10. Author:
  11. Wesley Witt (wesw) 17-Feb-1996
  12. --*/
  13. #include "wizard.h"
  14. #pragma hdrstop
  15. // ------------------------------------------------------------
  16. // Internal prototypes
  17. BOOL Win9xUpg(); // t-briand: added for Win9x upgrade process.
  18. WIZPAGE SetupWizardPages[WizPageMaximum] = {
  19. //
  20. // Device Status Page
  21. //
  22. {
  23. PSWIZB_NEXT, // valid buttons
  24. 0, // help id
  25. NULL, // title
  26. WizPageDeviceStatus, // page id
  27. DeviceStatusDlgProc, // dlg proc
  28. { 0, // size of struct
  29. 0, // flags
  30. NULL, // hinst (filled in at run time)
  31. MAKEINTRESOURCE(IDD_DEVICE_INIT_PAGE), // dlg template
  32. NULL, // icon
  33. NULL, // title
  34. CommonDlgProc, // dlg proc
  35. 0, // lparam
  36. NULL, // callback
  37. NULL // ref count
  38. }},
  39. //
  40. // Device Selection Page
  41. //
  42. {
  43. PSWIZB_NEXT, // valid buttons
  44. 0, // help id
  45. NULL, // title
  46. WizPageDeviceSelection, // page id
  47. DeviceSelectionDlgProc, // dlg proc
  48. { 0, // size of struct
  49. 0, // flags
  50. NULL, // hinst (filled in at run time)
  51. MAKEINTRESOURCE(IDD_WORKSTATION_DEVICE_SELECT), // dlg template
  52. NULL, // icon
  53. NULL, // title
  54. CommonDlgProc, // dlg proc
  55. 0, // lparam
  56. NULL, // callback
  57. NULL // ref count
  58. }},
  59. //
  60. // Server name page
  61. //
  62. {
  63. PSWIZB_NEXT, // valid buttons
  64. 0, // help id
  65. NULL, // title
  66. WizPageServerName, // page id
  67. ServerNameDlgProc, // dlg proc
  68. { 0, // size of struct
  69. 0, // flags
  70. NULL, // hinst (filled in at run time)
  71. MAKEINTRESOURCE(IDD_SERVER_NAME_PAGE), // dlg template
  72. NULL, // icon
  73. NULL, // title
  74. CommonDlgProc, // dlg proc
  75. 0, // lparam
  76. NULL, // callback
  77. NULL // ref count
  78. }},
  79. //
  80. // Exchange page
  81. //
  82. {
  83. PSWIZB_NEXT | PSWIZB_BACK, // valid buttons
  84. 0, // help id
  85. NULL, // title
  86. WizPageExchange, // page id
  87. ExchangeDlgProc, // dlg proc
  88. { 0, // size of struct
  89. 0, // flags
  90. NULL, // hinst (filled in at run time)
  91. MAKEINTRESOURCE(IDD_EXCHANGE_PAGE), // dlg template
  92. NULL, // icon
  93. NULL, // title
  94. CommonDlgProc, // dlg proc
  95. 0, // lparam
  96. NULL, // callback
  97. NULL // ref count
  98. }},
  99. //
  100. // File copy page
  101. //
  102. {
  103. PSWIZB_NEXT | PSWIZB_BACK, // valid buttons
  104. 0, // help id
  105. NULL, // title
  106. WizPageFileCopy, // page id
  107. FileCopyDlgProc, // dlg proc
  108. { 0, // size of struct
  109. 0, // flags
  110. NULL, // hinst (filled in at run time)
  111. MAKEINTRESOURCE(IDD_FILE_COPY_PAGE), // dlg template
  112. NULL, // icon
  113. NULL, // title
  114. CommonDlgProc, // dlg proc
  115. 0, // lparam
  116. NULL, // callback
  117. NULL // ref count
  118. }},
  119. //
  120. // Station Id page
  121. //
  122. {
  123. PSWIZB_NEXT | PSWIZB_BACK, // valid buttons
  124. 0, // help id
  125. NULL, // title
  126. WizPageStationId, // page id
  127. StationIdDlgProc, // dlg proc
  128. { 0, // size of struct
  129. 0, // flags
  130. NULL, // hinst (filled in at run time)
  131. MAKEINTRESOURCE(IDD_STATIONID_PAGE), // dlg template
  132. NULL, // icon
  133. NULL, // title
  134. CommonDlgProc, // dlg proc
  135. 0, // lparam
  136. NULL, // callback
  137. NULL // ref count
  138. }},
  139. //
  140. // Routing Printer Name Page
  141. //
  142. {
  143. PSWIZB_NEXT | PSWIZB_BACK, // valid buttons
  144. 0, // help id
  145. NULL, // title
  146. WizPageRoutePrint, // page id
  147. RoutePrintDlgProc, // dlg proc
  148. { 0, // size of struct
  149. 0, // flags
  150. NULL, // hinst (filled in at run time)
  151. MAKEINTRESOURCE(IDD_ROUTE_PRINT_PAGE), // dlg template
  152. NULL, // icon
  153. NULL, // title
  154. CommonDlgProc, // dlg proc
  155. 0, // lparam
  156. NULL, // callback
  157. NULL // ref count
  158. }},
  159. //
  160. // Routing Store Page
  161. //
  162. {
  163. PSWIZB_NEXT | PSWIZB_BACK, // valid buttons
  164. 0, // help id
  165. NULL, // title
  166. WizPageRouteStoreDir, // page id
  167. RouteStoreDlgProc, // dlg proc
  168. { 0, // size of struct
  169. 0, // flags
  170. NULL, // hinst (filled in at run time)
  171. MAKEINTRESOURCE(IDD_ROUTE_STOREDIR_PAGE), // dlg template
  172. NULL, // icon
  173. NULL, // title
  174. CommonDlgProc, // dlg proc
  175. 0, // lparam
  176. NULL, // callback
  177. NULL // ref count
  178. }},
  179. //
  180. // Routing Inbox Page
  181. //
  182. {
  183. PSWIZB_NEXT | PSWIZB_BACK, // valid buttons
  184. 0, // help id
  185. NULL, // title
  186. WizPageRouteInbox, // page id
  187. RouteMailDlgProc, // dlg proc
  188. { 0, // size of struct
  189. 0, // flags
  190. NULL, // hinst (filled in at run time)
  191. MAKEINTRESOURCE(IDD_ROUTE_INBOX_PAGE), // dlg template
  192. NULL, // icon
  193. NULL, // title
  194. CommonDlgProc, // dlg proc
  195. 0, // lparam
  196. NULL, // callback
  197. NULL // ref count
  198. }},
  199. //
  200. // Routing Security Page
  201. //
  202. {
  203. PSWIZB_NEXT | PSWIZB_BACK, // valid buttons
  204. 0, // help id
  205. NULL, // title
  206. WizPageRouteSecurity, // page id
  207. RouteSecurityDlgProc, // dlg proc
  208. { 0, // size of struct
  209. 0, // flags
  210. NULL, // hinst (filled in at run time)
  211. MAKEINTRESOURCE(IDD_ROUTE_USERPASS_PAGE), // dlg template
  212. NULL, // icon
  213. NULL, // title
  214. CommonDlgProc, // dlg proc
  215. 0, // lparam
  216. NULL, // callback
  217. NULL // ref count
  218. }},
  219. //
  220. // Platforms Page
  221. //
  222. {
  223. PSWIZB_NEXT, // valid buttons
  224. 0, // help id
  225. NULL, // title
  226. WizPagePlatforms, // page id
  227. PlatformsDlgProc, // dlg proc
  228. { 0, // size of struct
  229. 0, // flags
  230. NULL, // hinst (filled in at run time)
  231. MAKEINTRESOURCE(IDD_SERVER_PLATFORMS_PAGE), // dlg template
  232. NULL, // icon
  233. NULL, // title
  234. CommonDlgProc, // dlg proc
  235. 0, // lparam
  236. NULL, // callback
  237. NULL // ref count
  238. }},
  239. //
  240. // Last server page
  241. //
  242. {
  243. PSWIZB_FINISH, // valid buttons
  244. 0, // help id
  245. NULL, // title
  246. WizPageLast, // page id
  247. LastPageDlgProc, // dlg proc
  248. { 0, // size of struct
  249. 0, // flags
  250. NULL, // hinst (filled in at run time)
  251. MAKEINTRESOURCE(IDD_LAST_WIZARD_PAGE), // dlg template
  252. NULL, // icon
  253. NULL, // title
  254. CommonDlgProc, // dlg proc
  255. 0, // lparam
  256. NULL, // callback
  257. NULL // ref count
  258. }},
  259. //
  260. // Last uninstall page
  261. //
  262. {
  263. PSWIZB_FINISH, // valid buttons
  264. 0, // help id
  265. NULL, // title
  266. WizPageLastUninstall, // page id
  267. LastPageUninstallDlgProc, // dlg proc
  268. { 0, // size of struct
  269. 0, // flags
  270. NULL, // hinst (filled in at run time)
  271. MAKEINTRESOURCE(IDD_LAST_UNINSTALL_PAGE), // dlg template
  272. NULL, // icon
  273. NULL, // title
  274. CommonDlgProc, // dlg proc
  275. 0, // lparam
  276. NULL, // callback
  277. NULL // ref count
  278. }},
  279. //
  280. // Client's fax server name page
  281. //
  282. {
  283. PSWIZB_NEXT, // valid buttons
  284. 0, // help id
  285. NULL, // title
  286. WizPageClientServerName, // page id
  287. ClientServerNameDlgProc, // dlg proc
  288. { 0, // size of struct
  289. 0, // flags
  290. NULL, // hinst (filled in at run time)
  291. MAKEINTRESOURCE(IDD_CLIENT_SERVER_NAME_PAGE), // dlg template
  292. NULL, // icon
  293. NULL, // title
  294. CommonDlgProc, // dlg proc
  295. 0, // lparam
  296. NULL, // callback
  297. NULL // ref count
  298. }},
  299. //
  300. // Client's user info page
  301. //
  302. {
  303. PSWIZB_NEXT | PSWIZB_BACK, // valid buttons
  304. 0, // help id
  305. NULL, // title
  306. WizPageClientUserInfo, // page id
  307. ClientUserInfoDlgProc, // dlg proc
  308. { 0, // size of struct
  309. 0, // flags
  310. NULL, // hinst (filled in at run time)
  311. MAKEINTRESOURCE(IDD_CLIENT_USER_INFO_PAGE), // dlg template
  312. NULL, // icon
  313. NULL, // title
  314. CommonDlgProc, // dlg proc
  315. 0, // lparam
  316. NULL, // callback
  317. NULL // ref count
  318. }},
  319. //
  320. // Client file copy page
  321. //
  322. {
  323. PSWIZB_NEXT | PSWIZB_BACK, // valid buttons
  324. 0, // help id
  325. NULL, // title
  326. WizPageClientFileCopy, // page id
  327. ClientFileCopyDlgProc, // dlg proc
  328. { 0, // size of struct
  329. 0, // flags
  330. NULL, // hinst (filled in at run time)
  331. MAKEINTRESOURCE(IDD_FILE_COPY_PAGE), // dlg template
  332. NULL, // icon
  333. NULL, // title
  334. CommonDlgProc, // dlg proc
  335. 0, // lparam
  336. NULL, // callback
  337. NULL // ref count
  338. }},
  339. //
  340. // Last client page
  341. //
  342. {
  343. PSWIZB_FINISH, // valid buttons
  344. 0, // help id
  345. NULL, // title
  346. WizPageClientLast, // page id
  347. LastClientPageDlgProc, // dlg proc
  348. { 0, // size of struct
  349. 0, // flags
  350. NULL, // hinst (filled in at run time)
  351. MAKEINTRESOURCE(IDD_CLIENT_LAST_PAGE), // dlg template
  352. NULL, // icon
  353. NULL, // title
  354. CommonDlgProc, // dlg proc
  355. 0, // lparam
  356. NULL, // callback
  357. NULL // ref count
  358. }},
  359. //
  360. // Remote admin file copy page
  361. //
  362. {
  363. PSWIZB_NEXT, // valid buttons
  364. 0, // help id
  365. NULL, // title
  366. WizPageRemoteAdminCopy, // page id
  367. RemoteAdminFileCopyDlgProc, // dlg proc
  368. { 0, // size of struct
  369. 0, // flags
  370. NULL, // hinst (filled in at run time)
  371. MAKEINTRESOURCE(IDD_FILE_COPY_PAGE), // dlg template
  372. NULL, // icon
  373. NULL, // title
  374. CommonDlgProc, // dlg proc
  375. 0, // lparam
  376. NULL, // callback
  377. NULL // ref count
  378. }}
  379. };
  380. DWORD ServerWizardPages[] =
  381. {
  382. WizPageDeviceStatus,
  383. WizPageServerName,
  384. WizPagePlatforms,
  385. WizPageStationId,
  386. WizPageExchange,
  387. WizPageRouteStoreDir,
  388. WizPageRoutePrint,
  389. WizPageRouteInbox,
  390. WizPageRouteSecurity,
  391. WizPageFileCopy,
  392. WizPageLast,
  393. WizPageLastUninstall,
  394. (DWORD)-1
  395. };
  396. DWORD WorkstationWizardPages[] =
  397. {
  398. WizPageDeviceStatus,
  399. WizPageDeviceSelection,
  400. WizPageServerName,
  401. WizPageStationId,
  402. WizPageExchange,
  403. WizPageRouteStoreDir,
  404. WizPageRoutePrint,
  405. WizPageRouteInbox,
  406. WizPageRouteSecurity,
  407. WizPageFileCopy,
  408. WizPageLast,
  409. WizPageLastUninstall,
  410. (DWORD)-1
  411. };
  412. DWORD ClientWizardPages[] =
  413. {
  414. WizPageClientServerName,
  415. WizPageClientUserInfo,
  416. WizPageExchange,
  417. WizPageClientFileCopy,
  418. WizPageClientLast,
  419. WizPageLastUninstall,
  420. (DWORD)-1
  421. };
  422. DWORD PointPrintWizardPages[] =
  423. {
  424. WizPageClientUserInfo,
  425. WizPageClientFileCopy,
  426. (DWORD)-1
  427. };
  428. DWORD RemoteAdminPages[] =
  429. {
  430. WizPageRemoteAdminCopy,
  431. WizPageLast,
  432. WizPageLastUninstall,
  433. (DWORD)-1
  434. };
  435. HINSTANCE FaxWizModuleHandle;
  436. TCHAR SourceDirectory[4096];
  437. TCHAR ClientSetupServerName[128];
  438. BOOL MapiAvail;
  439. BOOL Unattended;
  440. BOOL SuppressReboot = FALSE;
  441. BOOL NtGuiMode;
  442. WIZ_DATA WizData;
  443. BOOL OkToCancel;
  444. BOOL PointPrintSetup;
  445. DWORD RequestedSetupType;
  446. DWORD InstallMode;
  447. DWORD Installed;
  448. DWORD InstallType;
  449. DWORD InstalledPlatforms;
  450. DWORD Enabled;
  451. DWORD InstallThreadError;
  452. DWORD
  453. FaxWizardDllInit(
  454. HINSTANCE hInstance,
  455. DWORD Reason,
  456. LPVOID Context
  457. )
  458. /*++
  459. Routine Description:
  460. DLL initialization function.
  461. Arguments:
  462. hInstance - Instance handle
  463. Reason - Reason for the entrypoint being called
  464. Context - Context record
  465. Return Value:
  466. TRUE - Initialization succeeded
  467. FALSE - Initialization failed
  468. --*/
  469. {
  470. if (Reason == DLL_PROCESS_ATTACH) {
  471. FaxWizModuleHandle = hInstance;
  472. DisableThreadLibraryCalls( hInstance );
  473. HeapInitialize( NULL, NULL, NULL, 0 );
  474. }
  475. if (Reason == DLL_PROCESS_DETACH) {
  476. HeapCleanup();
  477. }
  478. return TRUE;
  479. }
  480. BOOL
  481. WINAPI
  482. FaxWizInit(
  483. VOID
  484. )
  485. {
  486. InitializeStringTable();
  487. if (!NtGuiMode) {
  488. InitializeMapi();
  489. }
  490. GetInstallationInfo( &Installed, &InstallType, &InstalledPlatforms, &Enabled );
  491. //
  492. // Sequentially enumerate platforms.
  493. //
  494. EnumPlatforms[PROCESSOR_ARCHITECTURE_INTEL] = 0;
  495. EnumPlatforms[PROCESSOR_ARCHITECTURE_MIPS] = WRONG_PLATFORM;
  496. EnumPlatforms[PROCESSOR_ARCHITECTURE_ALPHA] = 1;
  497. EnumPlatforms[PROCESSOR_ARCHITECTURE_PPC] = WRONG_PLATFORM;
  498. return TRUE;
  499. }
  500. DWORD
  501. WINAPI
  502. FaxWizGetError(
  503. VOID
  504. )
  505. {
  506. return InstallThreadError;
  507. }
  508. VOID
  509. WINAPI
  510. FaxWizSetInstallMode(
  511. DWORD RequestedInstallMode,
  512. DWORD RequestedInstallType,
  513. LPWSTR AnswerFile
  514. )
  515. {
  516. InstallMode = RequestedInstallMode;
  517. InstallType = RequestedInstallType;
  518. if (InstallMode == (INSTALL_REMOVE | INSTALL_UNATTENDED) ) {
  519. InstallMode = INSTALL_REMOVE;
  520. Unattended = TRUE;
  521. }
  522. if (InstallMode == INSTALL_UNATTENDED) {
  523. //
  524. // initialize the answers
  525. //
  526. UnAttendInitialize( AnswerFile );
  527. //
  528. // set the install mode
  529. //
  530. if (_wcsicmp( UnattendAnswerTable[UAA_MODE].Answer.String, MODE_NEW ) == 0) {
  531. InstallMode = INSTALL_NEW;
  532. } else if (_wcsicmp( UnattendAnswerTable[UAA_MODE].Answer.String, MODE_UPGRADE ) == 0) {
  533. InstallMode = INSTALL_UPGRADE;
  534. } else if (_wcsicmp( UnattendAnswerTable[UAA_MODE].Answer.String, MODE_REMOVE ) == 0) {
  535. InstallMode = INSTALL_REMOVE;
  536. } else if (_wcsicmp( UnattendAnswerTable[UAA_MODE].Answer.String, MODE_DRIVERS ) == 0) {
  537. InstallMode = INSTALL_DRIVERS;
  538. } else {
  539. InstallMode = INSTALL_NEW;
  540. }
  541. if (InstallMode == INSTALL_UPGRADE && Installed == FALSE) {
  542. InstallMode = INSTALL_NEW;
  543. }
  544. //
  545. // remember that faxsetup is doing an unattended setup
  546. // this is the flag that all other code checks
  547. //
  548. Unattended = TRUE;
  549. }
  550. }
  551. BOOL
  552. WINAPI
  553. FaxWizPointPrint(
  554. LPTSTR DirectoryName,
  555. LPTSTR PrinterName
  556. )
  557. {
  558. DWORD len;
  559. LPTSTR p;
  560. len = _tcslen(DirectoryName);
  561. _tcscpy( SourceDirectory, DirectoryName );
  562. p = _tcschr( SourceDirectory, TEXT('\\') );
  563. if (p) {
  564. *p = 0;
  565. _tcscpy( ClientSetupServerName, &SourceDirectory[2] );
  566. *p = TEXT('\\');
  567. }
  568. if (SourceDirectory[len-1] != TEXT('\\')) {
  569. SourceDirectory[len] = TEXT('\\');
  570. SourceDirectory[len+1] = 0;
  571. }
  572. if (PrinterName[0] == TEXT('\\') && PrinterName[1] == TEXT('\\')) {
  573. _tcscpy( WizData.PrinterName, PrinterName );
  574. } else {
  575. WizData.PrinterName[0] = TEXT('\\');
  576. WizData.PrinterName[1] = TEXT('\\');
  577. WizData.PrinterName[2] = 0;
  578. _tcscat( WizData.PrinterName, PrinterName );
  579. }
  580. InstallMode = INSTALL_NEW;
  581. PointPrintSetup = TRUE;
  582. return TRUE;
  583. }
  584. VOID
  585. SetThisPlatform(
  586. VOID
  587. )
  588. {
  589. SYSTEM_INFO SystemInfo;
  590. GetSystemInfo( &SystemInfo );
  591. if ((SystemInfo.wProcessorArchitecture > 3) || (EnumPlatforms[SystemInfo.wProcessorArchitecture] == WRONG_PLATFORM)) {
  592. return;
  593. }
  594. Platforms[EnumPlatforms[SystemInfo.wProcessorArchitecture]].Selected = TRUE;
  595. }
  596. LPHPROPSHEETPAGE
  597. WINAPI
  598. FaxWizGetServerPages(
  599. LPDWORD PageCount
  600. )
  601. {
  602. SetThisPlatform();
  603. RequestedSetupType = SETUP_TYPE_SERVER;
  604. SetTitlesInStringTable();
  605. return CreateWizardPages( FaxWizModuleHandle, SetupWizardPages, ServerWizardPages, PageCount );
  606. }
  607. LPHPROPSHEETPAGE
  608. WINAPI
  609. FaxWizGetWorkstationPages(
  610. LPDWORD PageCount
  611. )
  612. {
  613. SetThisPlatform();
  614. RequestedSetupType = SETUP_TYPE_WORKSTATION;
  615. SetTitlesInStringTable();
  616. return CreateWizardPages( FaxWizModuleHandle, SetupWizardPages, WorkstationWizardPages, PageCount );
  617. }
  618. LPHPROPSHEETPAGE
  619. WINAPI
  620. FaxWizGetClientPages(
  621. LPDWORD PageCount
  622. )
  623. {
  624. SetThisPlatform();
  625. RequestedSetupType = SETUP_TYPE_CLIENT;
  626. SetTitlesInStringTable();
  627. return CreateWizardPages( FaxWizModuleHandle, SetupWizardPages, ClientWizardPages, PageCount );
  628. }
  629. LPHPROPSHEETPAGE
  630. WINAPI
  631. FaxWizGetPointPrintPages(
  632. LPDWORD PageCount
  633. )
  634. {
  635. SetThisPlatform();
  636. RequestedSetupType = SETUP_TYPE_POINT_PRINT;
  637. SetTitlesInStringTable();
  638. return CreateWizardPages( FaxWizModuleHandle, SetupWizardPages, PointPrintWizardPages, PageCount );
  639. }
  640. LPHPROPSHEETPAGE
  641. WINAPI
  642. FaxWizRemoteAdminPages(
  643. LPDWORD PageCount
  644. )
  645. {
  646. SetThisPlatform();
  647. RequestedSetupType = SETUP_TYPE_REMOTE_ADMIN;
  648. SetTitlesInStringTable();
  649. return CreateWizardPages( FaxWizModuleHandle, SetupWizardPages, RemoteAdminPages, PageCount );
  650. }
  651. PFNPROPSHEETCALLBACK WINAPI
  652. FaxWizGetPropertySheetCallback(
  653. VOID
  654. )
  655. {
  656. return WizardCallback;
  657. }
  658. DWORD
  659. DllRegisterServer(
  660. VOID
  661. )
  662. {
  663. OSVERSIONINFO OsVersion;
  664. DWORD ProductType;
  665. PROPSHEETHEADER psh;
  666. LPHPROPSHEETPAGE WizardPageHandles;
  667. DWORD PageCount;
  668. DWORD Size;
  669. LPTSTR EnvVar;
  670. BOOL UseDefaults = TRUE;
  671. SYSTEM_INFO SystemInfo;
  672. BOOL NtGuiModeUpgrade = FALSE;
  673. NtGuiMode = TRUE;
  674. if (!FaxWizInit()) {
  675. return 0;
  676. }
  677. ZeroMemory( &OsVersion, sizeof(OSVERSIONINFO) );
  678. OsVersion.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
  679. GetVersionEx( &OsVersion );
  680. ProductType = GetProductType();
  681. if (ProductType == 0) {
  682. return 0;
  683. }
  684. GetSystemInfo( &SystemInfo );
  685. SetThisPlatform();
  686. if (ProductType == PRODUCT_TYPE_WINNT) {
  687. RequestedSetupType = SETUP_TYPE_WORKSTATION;
  688. } else {
  689. RequestedSetupType = SETUP_TYPE_SERVER;
  690. }
  691. InstallMode = INSTALL_NEW;
  692. Unattended = TRUE;
  693. EnvVar = GetEnvVariable( TEXT("Upgrade") );
  694. if (EnvVar) {
  695. if (_wcsicmp( EnvVar, L"True" ) == 0) {
  696. InstallMode = INSTALL_UPGRADE;
  697. NtGuiModeUpgrade = TRUE;
  698. }
  699. MemFree( EnvVar );
  700. }
  701. if (InstallMode == INSTALL_UPGRADE && Installed == FALSE) {
  702. InstallMode = INSTALL_NEW;
  703. }
  704. EnvVar = GetEnvVariable( TEXT("UnattendFile") );
  705. if (EnvVar) {
  706. if (UnAttendInitialize( EnvVar )) {
  707. UseDefaults = FALSE;
  708. }
  709. MemFree( EnvVar );
  710. } else if(Win9xUpg()) {
  711. // t-briand: If we're upgrading from win9x, then we don't want to use the defaults.
  712. // The unattend answer table will be set as a side effect of the call to Win9xUpg().
  713. UseDefaults = FALSE;
  714. }
  715. if (UseDefaults) {
  716. UnattendAnswerTable[0].Answer.String = GetString( IDS_UAA_MODE );
  717. UnattendAnswerTable[1].Answer.String = GetString( IDS_UAA_PRINTER_NAME );
  718. UnattendAnswerTable[2].Answer.String = GetString( IDS_UAA_FAX_PHONE );
  719. UnattendAnswerTable[3].Answer.Bool = FALSE;
  720. UnattendAnswerTable[4].Answer.String = GetString( IDS_UAA_DEST_PROFILENAME );
  721. UnattendAnswerTable[5].Answer.Bool = FALSE;
  722. UnattendAnswerTable[6].Answer.String = GetString( IDS_UAA_ROUTE_PROFILENAME );
  723. UnattendAnswerTable[8].Answer.Bool = FALSE;
  724. UnattendAnswerTable[9].Answer.String = GetString( IDS_UAA_DEST_PRINTERLIST );
  725. UnattendAnswerTable[12].Answer.String = GetString( IDS_UAA_FAX_PHONE );
  726. UnattendAnswerTable[14].Answer.Bool = TRUE;
  727. UnattendAnswerTable[15].Answer.String = GetString( IDS_UAA_SERVER_NAME );
  728. UnattendAnswerTable[16].Answer.String = GetString( IDS_UAA_SENDER_NAME );
  729. UnattendAnswerTable[17].Answer.String = GetString( IDS_UAA_SENDER_FAX_AREA_CODE );
  730. UnattendAnswerTable[18].Answer.String = GetString( IDS_UAA_SENDER_FAX_NUMBER );
  731. UnattendAnswerTable[7].Answer.String =
  732. StringDup( Platforms[EnumPlatforms[SystemInfo.wProcessorArchitecture]].OsPlatform );
  733. UnattendAnswerTable[13].Answer.String = ExpandEnvironmentString( GetString( IDS_UAA_DEST_DIRPATH ) );
  734. if (UnattendAnswerTable[13].Answer.String == NULL) {
  735. return 0;
  736. }
  737. } else {
  738. if (UnattendAnswerTable[10].Answer.String) {
  739. MemFree( UnattendAnswerTable[10].Answer.String );
  740. }
  741. if (UnattendAnswerTable[11].Answer.String) {
  742. MemFree( UnattendAnswerTable[11].Answer.String );
  743. }
  744. }
  745. UnattendAnswerTable[10].Answer.String = NULL;
  746. UnattendAnswerTable[11].Answer.String = NULL;
  747. SetTitlesInStringTable();
  748. //
  749. // setup the wizard pages & property sheet
  750. //
  751. if (RequestedSetupType == SETUP_TYPE_WORKSTATION) {
  752. WizardPageHandles = CreateWizardPages( FaxWizModuleHandle, SetupWizardPages, WorkstationWizardPages, &PageCount );
  753. } else {
  754. WizardPageHandles = CreateWizardPages( FaxWizModuleHandle, SetupWizardPages, ServerWizardPages, &PageCount );
  755. }
  756. if (WizardPageHandles == NULL || PageCount == 0) {
  757. return 0;
  758. }
  759. psh.dwSize = sizeof(PROPSHEETHEADER);
  760. psh.dwFlags = PSH_WIZARD;
  761. psh.hwndParent = NULL;
  762. psh.hInstance = FaxWizModuleHandle;
  763. psh.pszIcon = NULL;
  764. psh.pszCaption = EMPTY_STRING;
  765. psh.nPages = PageCount;
  766. psh.nStartPage = 0;
  767. psh.phpage = WizardPageHandles;
  768. psh.pfnCallback = NULL;
  769. __try {
  770. PropertySheet( &psh );
  771. } __except (EXCEPTION_EXECUTE_HANDLER) {
  772. Size = GetExceptionCode();
  773. }
  774. return 0;
  775. }
  776. // Win9xUpg
  777. //
  778. // This routine is the hook for the Windows 9x upgrade process. It looks for
  779. // the fax95upg.inf file in the %SystemRoot% directory. If it's there, it
  780. // uses it to prime the unattend answers. If not, we're not upgrading from
  781. // win9x and it does nothing.
  782. //
  783. // As I write this, I'm wondering why the separate INF file was necessary instead
  784. // of the unattend file used by the rest of the migration process. Ah well.
  785. //
  786. // Parameters:
  787. // None.
  788. //
  789. // Returns:
  790. // TRUE if we're doing a Win9x upgrade; this implies that the unattend
  791. // answers are properly set at the end of the function. Returns FALSE
  792. // if not upgrading.
  793. //
  794. // Author:
  795. // Brian Dewey (t-briand) 1997-8-15
  796. BOOL
  797. Win9xUpg()
  798. {
  799. TCHAR szFaxInfPath[MAX_PATH]; // Holds the full path to the INF file.
  800. TCHAR szFaxInfPathRes[MAX_PATH]; // Path template from resource file.
  801. BOOL bReturn;
  802. if(!LoadString(FaxWizModuleHandle,
  803. IDS_W95_INF_NAME,
  804. szFaxInfPathRes,
  805. sizeof(szFaxInfPathRes))) {
  806. // Unable to load resource. Use default name.
  807. _tcscpy(szFaxInfPathRes, TEXT("%SystemRoot\\fax95upg.inf"));
  808. }
  809. ExpandEnvironmentStrings(szFaxInfPathRes,
  810. szFaxInfPath,
  811. sizeof(szFaxInfPath));
  812. // Assume success. The failure will be caught in UnAttendInitialize when I
  813. // give it a bogus filename.
  814. bReturn = UnAttendInitialize(szFaxInfPath);
  815. return bReturn;
  816. }