Leaked source code of windows server 2003
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.

3854 lines
134 KiB

  1. //**********************************************************************
  2. // File name: connwiz.cpp
  3. //
  4. // Main source file for the Internet Connection Wizard '98
  5. //
  6. // Functions:
  7. //
  8. // WinMain - Program entry point
  9. //
  10. // Copyright (c) 1992 - 1998 Microsoft Corporation. All rights reserved.
  11. //**********************************************************************
  12. #include "pre.h"
  13. #include "icwextsn.h"
  14. #ifndef ICWDEBUG
  15. #include "tutor.h"
  16. #endif //ICWDEBUG
  17. #include "iimgctx.h"
  18. #include "icwcfg.h"
  19. #include <stdio.h>
  20. #include "tchar.h"
  21. #include <netcon.h>
  22. // External functions
  23. #ifdef DEBUG
  24. extern void DoDesktopChanges(HINSTANCE hAppInst);
  25. #endif //DEBUG
  26. extern void UpdateDesktop(HINSTANCE hAppInst);
  27. extern void UpdateWelcomeRegSetting(BOOL bSetBit);
  28. extern void UndoDesktopChanges(HINSTANCE hAppInst);
  29. extern BOOL WasNotUpgrade();
  30. extern INT_PTR CALLBACK GenDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  31. extern BOOL SuperClassICWControls(void);
  32. extern BOOL RemoveICWControlsSuperClass(void);
  33. extern BOOL IsNT5();
  34. extern BOOL IsNT();
  35. extern BOOL IsWhistler();
  36. // local function prototypes
  37. BOOL AllocDialogIDList( void );
  38. BOOL DialogIDAlreadyInUse( UINT uDlgID );
  39. BOOL SetDialogIDInUse( UINT uDlgID, BOOL fInUse );
  40. static BOOL
  41. CheckOobeInfo(
  42. OUT LPTSTR pszOobeSwitch,
  43. OUT LPTSTR pszISPApp);
  44. static LONG
  45. MakeBold (
  46. IN HWND hwnd,
  47. IN BOOL fSize,
  48. IN LONG lfWeight);
  49. static LONG
  50. ReleaseBold(
  51. IN HWND hwnd);
  52. static VOID
  53. StartNCW(
  54. IN LPTSTR szShellNext,
  55. IN LPTSTR szShellNextParams);
  56. static VOID
  57. StartOOBE(
  58. IN LPTSTR pszCmdLine,
  59. IN LPTSTR pszOOBESwitch);
  60. static VOID
  61. StartISPApp(
  62. IN LPTSTR pszISPPath,
  63. IN LPTSTR pszCmdLine);
  64. static BOOL
  65. MyExecute(
  66. IN LPTSTR pszCmdLine);
  67. INT_PTR CALLBACK
  68. ChooseWizardDlgProc(
  69. IN HWND hwnd,
  70. IN UINT uMsg,
  71. IN WPARAM wParam,
  72. IN LPARAM lParam);
  73. // Return values of ChooseWizardDlgProc
  74. #define RUNWIZARD_CANCEL 0
  75. #define RUNWIZARD_NCW 1
  76. #define RUNWIZARD_OOBE 2
  77. #define ICW_CFGFLAGS_NONCW (ICW_CFGFLAG_IEAKMODE |\
  78. ICW_CFGFLAG_BRANDED |\
  79. ICW_CFGFLAG_SBS |\
  80. ICW_CFGFLAG_PRODCODE_FROM_CMDLINE |\
  81. ICW_CFGFLAG_OEMCODE_FROM_CMDLINE |\
  82. ICW_CFGFLAG_DO_NOT_OVERRIDE_ALLOFFERS)
  83. //Branding file default names
  84. #define BRANDING_DEFAULT_HTML TEXT("BRANDED.HTM")
  85. #define BRANDING_DEFAULT_HEADER_BMP TEXT("BRANDHDR.BMP")
  86. #define BRANDING_DEFAULT_WATERMARK_BMP TEXT("BRANDWTR.BMP")
  87. #define ICW_NO_APP_TITLE TEXT("-1")
  88. // Definitions for command line parameters
  89. #define OOBE_CMD TEXT("/oobe")
  90. #define PRECONFIG_CMD TEXT("/preconfig")
  91. #define OFFLINE_CMD TEXT("/offline")
  92. #define LOCAL_CMD TEXT("/local")
  93. #define MSN_CMD TEXT("/xicw")
  94. #define ICW_OOBE_TITLE TEXT("icwoobe.exe")
  95. #define ICW_APP_TITLE TEXT("icwconn1.exe")
  96. #define OOBE_APP_TITLE TEXT("msoobe.exe")
  97. #define OOBE_MSOBMAINDLL TEXT("msobmain.dll")
  98. static const TCHAR cszSignup[] = TEXT("Signup");
  99. static const TCHAR cszISPSignup[] = TEXT("ISPSignup");
  100. static const TCHAR cszISPSignupApp[] = TEXT("ISPSignupApp");
  101. static const TCHAR cszOOBEINFOINI[] = TEXT("oobeinfo.ini");
  102. static const TCHAR cszNone[] = TEXT("None");
  103. static const TCHAR cszMSN[] = TEXT("MSN");
  104. static const TCHAR cszOffline[] = TEXT("Offline");
  105. static const TCHAR cszPreconfig[] = TEXT("preconfig");
  106. static const TCHAR cszLocal[] = TEXT("local");
  107. //static const TCHAR cszMSNIconKey[] = TEXT("CLSID\\{88667D10-10F0-11D0-8150-00AA00BF8457}");
  108. static const TCHAR cszMSNIconKey[] = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\explorer\\Desktop\\NameSpace\\{88667D10-10F0-11D0-8150-00AA00BF8457}");
  109. #pragma data_seg(".data")
  110. // Global state vars
  111. #ifndef ICWDEBUG
  112. CICWTutorApp* g_pICWTutorApp;
  113. #endif //ICWDEBUG
  114. INT _convert; // For string conversion
  115. HINSTANCE g_hInstance;
  116. UINT g_uICWCONNUIFirst;
  117. UINT g_uICWCONNUILast;
  118. BOOL g_bUserIsAdmin = FALSE;
  119. BOOL g_bUserIsIEAKRestricted = FALSE;
  120. BOOL g_bRetProcessCmdLine = FALSE;
  121. BOOL g_OEMOOBE = FALSE;
  122. const TCHAR c_szOEMCustomizationDir[] = TEXT("ICW");
  123. const TCHAR c_szOEMCustomizationFile[] = TEXT("OEMCUST.INI");
  124. CICWApp *g_pICWApp = NULL;
  125. WNDPROC g_lpfnOldWndProc = NULL;
  126. WIZARDSTATE* gpWizardState = NULL; // pointer to global wizard state struct
  127. CICWExtension* g_pCICWExtension = NULL;
  128. CICWExtension* g_pCINETCFGExtension = NULL;
  129. DWORD* g_pdwDialogIDList = NULL;
  130. HANDLE g_hMapping = NULL;
  131. DWORD g_dwDialogIDListSize = 0;
  132. BOOL g_bRunDefaultHtm = FALSE; //BOOL the will force IE to launch even though shell next is NULL
  133. BOOL g_fICWCONNUILoaded = FALSE;
  134. BOOL g_fINETCFGLoaded = FALSE;
  135. BOOL g_bHelpShown = FALSE;
  136. BOOL gfQuitWizard = FALSE; // global flag used to signal that we want to terminate the wizard ourselves
  137. BOOL gfUserCancelled = FALSE; // global flag used to signal that the user cancelled
  138. BOOL gfUserBackedOut = FALSE; // global flag used to signal that the user pressed Back on the first page
  139. BOOL gfUserFinished = FALSE; // global flag used to signal that the user pressed Finish on the final page
  140. BOOL gfBackedUp = FALSE; // Added to preserve the REBOOT state from conn1 -> manual and manual -> conn1 - MKarki
  141. BOOL gfReboot = FALSE; // DJM BUGBUG: We should only need 1 of these
  142. BOOL g_bReboot = FALSE;
  143. BOOL g_bRunOnce = FALSE;
  144. BOOL g_bShortcutEntry = FALSE;
  145. BOOL g_bNewIspPath = TRUE;
  146. BOOL g_bSkipIntro = FALSE;
  147. BOOL g_bAutoConfigPath = FALSE;
  148. BOOL g_bManualPath = FALSE;
  149. BOOL g_bLanPath = FALSE;
  150. BOOL g_bAllowCancel = FALSE;
  151. TCHAR* g_pszCmdLine = NULL;
  152. BOOL g_bDebugOEMCustomization = FALSE;
  153. //
  154. // Table of data for each wizard page
  155. //
  156. // This includes the dialog template ID and pointers to functions for
  157. // each page. Pages need only provide pointers to functions when they
  158. // want non-default behavior for a certain action (init,next/back,cancel,
  159. // dlg ctrl).
  160. //
  161. #ifdef ICWDEBUG
  162. PAGEINFO PageInfo[EXE_NUM_WIZARD_PAGES] =
  163. {
  164. { IDD_ICWDEBUG_OFFER, FALSE, DebugOfferInitProc, NULL, DebugOfferOKProc, DebugOfferCmdProc, NULL, DebugOfferNotifyProc, IDS_ICWDEBUG_OFFER_TITLE, 0, 0, NULL, NULL},
  165. { IDD_ICWDEBUG_SETTINGS, FALSE, DebugSettingsInitProc, NULL, DebugSettingsOKProc, DebugSettingsCmdProc, NULL, NULL, IDS_ICWDEBUG_SETTINGS_TITLE, 0, 0, NULL, NULL},
  166. { IDD_PAGE_END, FALSE, EndInitProc, NULL, EndOKProc, NULL, NULL, NULL, 0, 0, 0, NULL, NULL}
  167. };
  168. #else //!def ICWDEBUG
  169. PAGEINFO PageInfo[EXE_NUM_WIZARD_PAGES] =
  170. {
  171. { IDD_PAGE_INTRO, FALSE, IntroInitProc, NULL, IntroOKProc, IntroCmdProc, NULL, NULL, 0, 0, 0, NULL, NULL },
  172. { IDD_PAGE_MANUALOPTIONS, FALSE, ManualOptionsInitProc, NULL, ManualOptionsOKProc, ManualOptionsCmdProc,NULL, NULL, IDS_MANUALOPTS_TITLE, 0, 0, NULL, NULL },
  173. { IDD_PAGE_AREACODE, FALSE, AreaCodeInitProc, NULL, AreaCodeOKProc, AreaCodeCmdProc, NULL, NULL, IDS_STEP1_TITLE, 0, IDA_AREACODE, NULL, NULL },
  174. { IDD_PAGE_REFSERVDIAL, FALSE, RefServDialInitProc, RefServDialPostInitProc, RefServDialOKProc, NULL, RefServDialCancelProc, NULL, IDS_STEP1_TITLE, 0, 0, NULL, NULL },
  175. { IDD_PAGE_END, FALSE, EndInitProc, NULL, EndOKProc, NULL, NULL, NULL, 0, 0, 0, NULL, NULL },
  176. { IDD_PAGE_ENDOEMCUSTOM, FALSE, EndInitProc, NULL, EndOKProc, NULL, NULL, NULL, IDS_OEMCUST_END_TITLE, 0, IDA_ENDOEMCUSTOM, NULL, NULL },
  177. { IDD_PAGE_ENDOLS, FALSE, EndOlsInitProc, NULL, NULL, NULL, NULL, NULL, IDS_ENDOLS_TITLE, 0, 0, NULL, NULL },
  178. { IDD_PAGE_DIALERROR, FALSE, DialErrorInitProc, NULL, DialErrorOKProc, DialErrorCmdProc, NULL, NULL, IDS_DIALING_ERROR_TITLE, 0, IDA_DIALERROR, NULL, NULL },
  179. { IDD_PAGE_MULTINUMBER, FALSE, MultiNumberInitProc, NULL, MultiNumberOKProc, NULL, NULL, NULL, IDS_STEP1_TITLE, 0, 0, NULL, NULL },
  180. { IDD_PAGE_SERVERROR, FALSE, ServErrorInitProc, NULL, ServErrorOKProc, ServErrorCmdProc, NULL, NULL, IDS_SERVER_ERROR_TITLE, 0, 0, NULL, NULL },
  181. { IDD_PAGE_BRANDEDINTRO, TRUE, BrandedIntroInitProc, BrandedIntroPostInitProc, BrandedIntroOKProc, NULL, NULL, NULL, 0, 0, 0, NULL, NULL },
  182. { IDD_PAGE_INTRO2, FALSE, IntroInitProc, NULL, IntroOKProc, NULL, NULL, NULL, IDS_STEP1_TITLE, 0, IDA_INTRO2, NULL, NULL },
  183. { IDD_PAGE_DEFAULT, FALSE, ISPErrorInitProc, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL },
  184. { IDD_PAGE_SBSINTRO, FALSE, SbsInitProc, NULL, SbsIntroOKProc, NULL, NULL, NULL, 0, 0, 0, NULL, NULL }
  185. };
  186. #endif //ICWDEBUG
  187. // Global Command Line Parameters
  188. TCHAR g_szOemCode [MAX_PATH+1] = TEXT("");
  189. TCHAR g_szProductCode [MAX_PATH+1] = TEXT("");
  190. TCHAR g_szPromoCode [MAX_PROMO] = TEXT("");
  191. TCHAR g_szShellNext [MAX_PATH+1] = TEXT("\0nogood");
  192. TCHAR g_szShellNextParams [MAX_PATH+1] = TEXT("\0nogood");
  193. // File names used for branded operation
  194. TCHAR g_szBrandedHTML [MAX_PATH] = TEXT("\0");
  195. TCHAR g_szBrandedHeaderBMP [MAX_PATH] = TEXT("\0");
  196. TCHAR g_szBrandedWatermarkBMP [MAX_PATH] = TEXT("\0");
  197. #pragma data_seg()
  198. //+----------------------------------------------------------------------------
  199. //
  200. // Function: IsOemVer
  201. //
  202. // Synopsis: This function will determine if the machine is an OEM system.
  203. //
  204. // Arguments: None
  205. //
  206. // Returns: TRUE - OEM system; FALSE - Retail Win 98 OSR
  207. //
  208. // History: 3/26/99 JCohen Created
  209. //
  210. //-----------------------------------------------------------------------------
  211. typedef BOOL (WINAPI * ISOEMVER)();
  212. BOOL IsOemVer()
  213. {
  214. BOOL bOEMVer = FALSE;
  215. TCHAR szOOBEPath [MAX_PATH] = TEXT("\0");
  216. TCHAR szOOBEDir [MAX_PATH] = TEXT("\0");
  217. ISOEMVER lpfnIsOEMVer = NULL;
  218. HINSTANCE hMsobMainDLL = NULL;
  219. //Try and get the path from the OEM file
  220. GetSystemDirectory(szOOBEPath, MAX_PATH);
  221. lstrcat(szOOBEPath, TEXT("\\oobe"));
  222. lstrcat(szOOBEPath, TEXT("\\"));
  223. lstrcat(szOOBEPath, OOBE_MSOBMAINDLL);
  224. hMsobMainDLL = LoadLibrary(szOOBEPath);
  225. if (hMsobMainDLL)
  226. {
  227. lpfnIsOEMVer = (ISOEMVER)GetProcAddress(hMsobMainDLL, "IsOemVer");
  228. if (NULL != lpfnIsOEMVer)
  229. {
  230. bOEMVer = lpfnIsOEMVer();
  231. }
  232. FreeLibrary(hMsobMainDLL);
  233. }
  234. return (bOEMVer);
  235. }
  236. //+----------------------------------------------------------------------------
  237. //
  238. // Function: CheckOobeInfo
  239. //
  240. // Synopsis: This function determines if the OOBE/ISP App should be run by
  241. // checking %windir%\system32\oobe\oobeinfo.ini.
  242. //
  243. // Arguments: pszOobeSwitch - OOBE additional command line arguments
  244. // assume size is at least MAX_PATH characters
  245. //
  246. // pszISPApp - output empty string unless ISP App is found;
  247. // assume size is at least MAX_PATH characters
  248. //
  249. // Returns: TRUE - OOBE/ISP App should run; FALSE - otherwise
  250. //
  251. // History: 25/11/99 Vyung Created
  252. //
  253. //-----------------------------------------------------------------------------
  254. BOOL
  255. CheckOobeInfo(
  256. OUT LPTSTR pszOobeSwitch,
  257. OUT LPTSTR pszISPApp)
  258. {
  259. BOOL bLaunchOOBE = TRUE;
  260. TCHAR szOOBEInfoINIFile[MAX_PATH] = TEXT("\0");
  261. TCHAR szISPSignup[MAX_PATH] = TEXT("\0");
  262. TCHAR szOOBEPath [MAX_PATH] = TEXT("\0");
  263. pszISPApp[0] = TEXT('\0');
  264. pszOobeSwitch[0] = TEXT('\0');
  265. GetSystemDirectory(szOOBEPath, MAX_PATH);
  266. lstrcat(szOOBEPath, TEXT("\\oobe"));
  267. SearchPath(szOOBEPath, cszOOBEINFOINI, NULL, MAX_PATH, szOOBEInfoINIFile, NULL);
  268. GetPrivateProfileString(cszSignup,
  269. cszISPSignup,
  270. TEXT(""),
  271. szISPSignup,
  272. MAX_PATH,
  273. szOOBEInfoINIFile);
  274. if (0 == lstrcmpi(szISPSignup, cszNone))
  275. {
  276. bLaunchOOBE = FALSE;
  277. }
  278. else if (0 == lstrcmpi(szISPSignup, cszMSN))
  279. {
  280. if (IsWhistler())
  281. {
  282. GetPrivateProfileString(cszSignup,
  283. cszISPSignupApp,
  284. TEXT(""),
  285. pszISPApp,
  286. MAX_PATH,
  287. szOOBEInfoINIFile);
  288. if (pszISPApp[0] == TEXT('\0'))
  289. {
  290. lstrcpy(pszOobeSwitch, MSN_CMD);
  291. }
  292. }
  293. else
  294. {
  295. HKEY hKey = 0;
  296. RegOpenKey(HKEY_LOCAL_MACHINE,cszMSNIconKey,&hKey);
  297. if (hKey)
  298. {
  299. RegCloseKey(hKey);
  300. }
  301. else
  302. {
  303. bLaunchOOBE = FALSE;
  304. }
  305. }
  306. }
  307. else if (0 == lstrcmpi(szISPSignup, cszOffline))
  308. {
  309. lstrcpy(pszOobeSwitch, OFFLINE_CMD);
  310. }
  311. else if (0 == lstrcmpi(szISPSignup, cszPreconfig))
  312. {
  313. bLaunchOOBE = FALSE;
  314. }
  315. else if (0 == lstrcmpi(szISPSignup, cszLocal))
  316. {
  317. lstrcpy(pszOobeSwitch, LOCAL_CMD);
  318. }
  319. return bLaunchOOBE;
  320. }
  321. // ############################################################################
  322. //
  323. // 5/23/97 jmazner Olympus #4157
  324. // Spaces are returned as a token
  325. // modified to consider anything between paired double quotes to be a single token
  326. // For example, the following consists of 9 tokens (4 spaces and 5 cmds)
  327. //
  328. // first second "this is the third token" fourth "fifth"
  329. //
  330. // The quote marks are included in the returned string (pszOut)
  331. void GetCmdLineToken(LPTSTR *ppszCmd, LPTSTR pszOut)
  332. {
  333. LPTSTR c;
  334. int i = 0;
  335. BOOL fInQuote = FALSE;
  336. c = *ppszCmd;
  337. pszOut[0] = *c;
  338. if (!*c)
  339. return;
  340. if (*c == ' ')
  341. {
  342. pszOut[1] = '\0';
  343. *ppszCmd = c+1;
  344. return;
  345. }
  346. else if( '"' == *c )
  347. {
  348. fInQuote = TRUE;
  349. }
  350. NextChar:
  351. i++;
  352. c++;
  353. if( !*c || (!fInQuote && (*c == ' ')) )
  354. {
  355. pszOut[i] = '\0';
  356. *ppszCmd = c;
  357. return;
  358. }
  359. else if( fInQuote && (*c == '"') )
  360. {
  361. fInQuote = FALSE;
  362. pszOut[i] = *c;
  363. i++;
  364. c++;
  365. pszOut[i] = '\0';
  366. *ppszCmd = c;
  367. return;
  368. }
  369. else
  370. {
  371. pszOut[i] = *c;
  372. goto NextChar;
  373. }
  374. }
  375. BOOL GetFilteredCmdLineToken(LPTSTR *ppszCmd, LPTSTR pszOut)
  376. {
  377. if(**ppszCmd != '/')
  378. {
  379. GetCmdLineToken(ppszCmd, pszOut);
  380. return TRUE;
  381. }
  382. return FALSE;
  383. }
  384. #define INETCFG_ISSMARTSTART "IsSmartStart"
  385. #define INETCFG_ISSMARTSTARTEX "IsSmartStartEx"
  386. #define SMART_RUNICW TRUE
  387. #define SMART_QUITICW FALSE
  388. //+----------------------------------------------------------------------------
  389. //
  390. // Function: MyIsSmartStartEx
  391. //
  392. // Synopsis: This function will determine if the ICW should be run. The
  393. // decision is made based on the current state of the user's machine.
  394. //
  395. // Arguments: none
  396. //
  397. // Returns: TRUE - run ICW; FALSE - quit now
  398. //
  399. // History: 25/11/97 Vyung Created
  400. //
  401. //-----------------------------------------------------------------------------
  402. BOOL MyIsSmartStartEx(LPTSTR lpszConnectionName, DWORD dwBufLen)
  403. {
  404. BOOL bRC = SMART_RUNICW;
  405. PFNIsSmartStart fp = NULL;
  406. HINSTANCE hInetCfg;
  407. // Load DLL and API
  408. hInetCfg = LoadLibrary(TEXT("inetcfg.dll"));
  409. if (hInetCfg)
  410. {
  411. if (NULL == lpszConnectionName)
  412. {
  413. PFNIsSmartStart fp = NULL;
  414. if (fp = (PFNIsSmartStart) GetProcAddress(hInetCfg,INETCFG_ISSMARTSTART))
  415. {
  416. // Call smart start
  417. bRC = (BOOL)fp();
  418. }
  419. }
  420. else
  421. {
  422. PFNIsSmartStartEx fp = NULL;
  423. if (fp = (PFNIsSmartStartEx) GetProcAddress(hInetCfg,INETCFG_ISSMARTSTARTEX))
  424. {
  425. // Call smart start
  426. bRC = (BOOL)fp(lpszConnectionName, dwBufLen);
  427. }
  428. }
  429. FreeLibrary(hInetCfg);
  430. }
  431. return bRC;
  432. }
  433. // Used below to load a bitmap file
  434. void CALLBACK ImgCtx_Callback(void* pIImgCtx,void* pfDone)
  435. {
  436. ASSERT(pfDone);
  437. *(BOOL*)pfDone = TRUE;
  438. return;
  439. }
  440. //+----------------------------------------------------------------------------
  441. //
  442. // This function will load a specified branded bitmap
  443. //
  444. //-----------------------------------------------------------------------------
  445. #define BRANDED_WATERMARK 1
  446. #define BRANDED_HEADER 2
  447. HBITMAP LoadBrandedBitmap
  448. (
  449. int iType
  450. )
  451. {
  452. HRESULT hr;
  453. IImgCtx *pIImgCtx;
  454. BSTR bstrFile;
  455. TCHAR szURL[INTERNET_MAX_URL_LENGTH];
  456. HBITMAP hbm = NULL;
  457. // Create an ImgCtx object to load/convert the bitmap
  458. hr = CoCreateInstance(CLSID_IImgCtx, NULL, CLSCTX_INPROC_SERVER,
  459. IID_IImgCtx, (void**)&pIImgCtx);
  460. if (FAILED(hr))
  461. return NULL;
  462. ASSERT(pIImgCtx);
  463. if (iType == BRANDED_WATERMARK)
  464. wsprintf (szURL, TEXT("FILE://%s"), g_szBrandedWatermarkBMP);
  465. else
  466. wsprintf (szURL, TEXT("FILE://%s"), g_szBrandedHeaderBMP);
  467. // "Download" the image
  468. bstrFile = A2W(szURL);
  469. hr = pIImgCtx->Load(bstrFile, 0);
  470. if (SUCCEEDED(hr))
  471. {
  472. ULONG fState;
  473. SIZE sz;
  474. pIImgCtx->GetStateInfo(&fState, &sz, TRUE);
  475. // If we are not complete, then wait for the download to complete
  476. if (!(fState & (IMGLOAD_COMPLETE | IMGLOAD_ERROR)))
  477. {
  478. BOOL fDone = FALSE;
  479. hr = pIImgCtx->SetCallback(ImgCtx_Callback, &fDone);
  480. if (SUCCEEDED(hr))
  481. {
  482. hr = pIImgCtx->SelectChanges(IMGCHG_COMPLETE, 0, TRUE);
  483. if (SUCCEEDED(hr))
  484. {
  485. MSG msg;
  486. BOOL fMsg;
  487. // HACK: restrict the message pump to those messages we know that URLMON and
  488. // HACK: the imageCtx stuff needs, otherwise we will be pumping messages for
  489. // HACK: windows we shouldn't be pumping right now...
  490. while(!fDone )
  491. {
  492. fMsg = PeekMessage(&msg, NULL, WM_USER + 1, WM_USER + 4, PM_REMOVE );
  493. if (!fMsg)
  494. fMsg = PeekMessage( &msg, NULL, WM_APP + 2, WM_APP + 2, PM_REMOVE );
  495. if (!fMsg)
  496. {
  497. // go to sleep until we get a new message....
  498. WaitMessage();
  499. continue;
  500. }
  501. TranslateMessage(&msg);
  502. DispatchMessage(&msg);
  503. }
  504. }
  505. }
  506. pIImgCtx->Disconnect();
  507. }
  508. // Get the Final state info, incase we just had to loop above
  509. hr = pIImgCtx->GetStateInfo(&fState, &sz, TRUE);
  510. if (SUCCEEDED(hr) && (fState & IMGLOAD_COMPLETE))
  511. {
  512. // OK, create our compatible bitmap, and blt in the one just loaded
  513. HDC hdcScreen = GetDC(NULL);
  514. if (hdcScreen)
  515. {
  516. if (NULL != (hbm = CreateCompatibleBitmap(hdcScreen, sz.cx, sz.cy)))
  517. {
  518. HDC hdcImgDst = CreateCompatibleDC(NULL);
  519. if (hdcImgDst)
  520. {
  521. HGDIOBJ hbmOld = SelectObject(hdcImgDst, hbm);
  522. hr = pIImgCtx->StretchBlt(hdcImgDst,
  523. 0,
  524. 0,
  525. sz.cx,
  526. sz.cy,
  527. 0,
  528. 0,
  529. sz.cx,
  530. sz.cy,
  531. SRCCOPY);
  532. SelectObject(hdcImgDst, hbmOld);
  533. DeleteDC(hdcImgDst);
  534. if (FAILED(hr))
  535. {
  536. DeleteObject(hbm);
  537. hbm = NULL;
  538. }
  539. }
  540. else
  541. {
  542. DeleteObject(hbm);
  543. hbm = NULL;
  544. }
  545. }
  546. DeleteDC(hdcScreen);
  547. }
  548. }
  549. }
  550. pIImgCtx->Release();
  551. return (hbm);
  552. }
  553. //+----------------------------------------------------------------------------
  554. //
  555. // This function will check to see if OEM branding is allowed, and if so, then did the OEM provide
  556. // the necessary branding pieces
  557. // TRUE means the OEM wants branding AND is allowed to brand
  558. // FALSE means no OEM branding will be done
  559. //
  560. //-----------------------------------------------------------------------------
  561. BOOL bCheckForOEMBranding
  562. (
  563. void
  564. )
  565. {
  566. BOOL bRet = FALSE;
  567. HANDLE hFile;
  568. // Check for required branding files. To brand an OEM needs to supply a first
  569. // page HTML file, and optionally, a header bitmap, and a final page graphic (watermark)
  570. hFile = CreateFile((LPCTSTR)g_szBrandedHTML,
  571. GENERIC_READ,
  572. FILE_SHARE_READ,
  573. 0,
  574. OPEN_EXISTING,
  575. 0,
  576. 0);
  577. if (INVALID_HANDLE_VALUE != hFile)
  578. {
  579. bRet = TRUE;
  580. CloseHandle(hFile);
  581. }
  582. return bRet;
  583. }
  584. BOOL ValidateFile(TCHAR* pszFile)
  585. {
  586. ASSERT(pszFile);
  587. DWORD dwFileType = GetFileAttributes(pszFile);
  588. if ((dwFileType == 0xFFFFFFFF) || (dwFileType == FILE_ATTRIBUTE_DIRECTORY))
  589. return FALSE;
  590. return TRUE;
  591. }
  592. //+----------------------------------------------------------------------------
  593. //
  594. // Function: SetDefaultProductCode
  595. //
  596. // Arguments: pszBuffer - buffer that will contain the default product code
  597. // dwLen - size of pszBuffer
  598. //
  599. // Returns: ERROR_SUCCESS if it succeded
  600. //
  601. // History: 1-20-96 ChrisK Created
  602. //
  603. //-----------------------------------------------------------------------------
  604. DWORD SetDefaultProductCode (LPTSTR pszBuffer, DWORD dwLen)
  605. {
  606. DWORD dwRet = ERROR_SUCCESS, dwType = 0;
  607. HKEY hkey = NULL;
  608. Assert(pszBuffer);
  609. // Open key
  610. dwRet = RegOpenKey(HKEY_LOCAL_MACHINE,
  611. TEXT("Software\\Microsoft\\Internet Connection Wizard"),&hkey);
  612. if (ERROR_SUCCESS != dwRet)
  613. goto SetDefaultProductCodeExit;
  614. // Read key
  615. dwRet = RegQueryValueEx(hkey,TEXT("Default Product Code"),NULL,
  616. &dwType,(LPBYTE)pszBuffer,&dwLen);
  617. if (ERROR_SUCCESS != dwRet)
  618. goto SetDefaultProductCodeExit;
  619. SetDefaultProductCodeExit:
  620. if (NULL != hkey)
  621. RegCloseKey(hkey);
  622. if (ERROR_SUCCESS != dwRet)
  623. pszBuffer[0] = '\0';
  624. return dwRet;
  625. }
  626. //GetShellNext
  627. //
  628. // 5/21/97 jmazner Olympus #4157
  629. // usage: /shellnext c:\path\executeable [parameters]
  630. // the token following nextapp will be shellExec'd at the
  631. // end of the "current" path. It can be anything that the shell
  632. // knows how to handle -- an .exe, a URL, etc.. If executable
  633. // name contains white space (eg: c:\program files\foo.exe), it
  634. // should be wrapped in double quotes, "c:\program files\foo.exe"
  635. // This will cause us to treat it as a single token.
  636. //
  637. // all consecutive subsequent tokens will
  638. // be passed to ShellExec as the parameters until a token is
  639. // encountered of the form /<non-slash character>. That is to say,
  640. // the TCHARacter combination // will be treated as an escape character
  641. //
  642. // this is easiest to explain by way of examples.
  643. //
  644. // examples of usage:
  645. //
  646. // icwconn1.exe /shellnext "C:\prog files\wordpad.exe" file.txt
  647. // icwconn1.exe /prod IE /shellnext msimn.exe /promo MCI
  648. // icwconn1.exe /shellnext msimn.exe //START_MAIL /promo MCI
  649. //
  650. // the executeable string and parameter string are limited to
  651. // a length of MAX_PATH
  652. //
  653. void GetShellNextToken(LPTSTR szOut, LPTSTR szCmdLine)
  654. {
  655. if (lstrcmpi(szOut,SHELLNEXT_CMD)==0)
  656. {
  657. // next token is expected to be white space
  658. GetCmdLineToken(&szCmdLine,szOut);
  659. if (szOut[0])
  660. {
  661. ZeroMemory(g_szShellNext,sizeof(g_szShellNext));
  662. ZeroMemory(g_szShellNextParams,sizeof(g_szShellNextParams));
  663. //this should be the thing to ShellExec
  664. if(GetFilteredCmdLineToken(&szCmdLine,szOut))
  665. {
  666. // watch closely, this gets a bit tricky
  667. //
  668. // if this command begins with a double quote, assume it ends
  669. // in a matching quote. We do _not_ want to store the
  670. // quotes, however, since ShellExec doesn't parse them out.
  671. if( '"' != szOut[0] )
  672. {
  673. // no need to worry about any of this quote business
  674. lstrcpy( g_szShellNext, szOut );
  675. }
  676. else
  677. {
  678. lstrcpy( g_szShellNext, &szOut[1] );
  679. g_szShellNext[lstrlen(g_szShellNext) - 1] = '\0';
  680. }
  681. // now read in everything up to the next command line switch
  682. // and consider it to be the parameter. Treat the sequence
  683. // "//" as an escape sequence, and allow it through.
  684. // Example:
  685. // the token /whatever is considered to be a switch to
  686. // icwconn1, and thus will break us out of the whle loop.
  687. //
  688. // the token //something is should be interpreted as a
  689. // command line /something to the the ShellNext app, and
  690. // should not break us out of the while loop.
  691. GetCmdLineToken(&szCmdLine,szOut);
  692. while( szOut[0] )
  693. {
  694. if( '/' == szOut[0] )
  695. {
  696. if( '/' != szOut[1] )
  697. {
  698. // it's not an escape sequence, so we're done
  699. break;
  700. }
  701. else
  702. {
  703. // it is an escape sequence, so store it in
  704. // the parameter list, but remove the first /
  705. lstrcat( g_szShellNextParams, &szOut[1] );
  706. }
  707. }
  708. else
  709. {
  710. lstrcat( g_szShellNextParams, szOut );
  711. }
  712. GetCmdLineToken(&szCmdLine,szOut);
  713. }
  714. }
  715. }
  716. }
  717. }
  718. // Process the incomming command line
  719. BOOL ProcessCommandLine
  720. (
  721. HINSTANCE hInstance,
  722. LPTSTR szCmdLine
  723. )
  724. {
  725. TCHAR szOut[MAX_PATH];
  726. BOOL bOOBESwitch = FALSE;
  727. // Get the first token
  728. GetCmdLineToken(&szCmdLine,szOut);
  729. while (szOut[0])
  730. {
  731. if (g_OEMOOBE)
  732. {
  733. if((0 == lstrcmpi(szOut, OOBE_CMD)) ||
  734. (0 == lstrcmpi(szOut, SHELLNEXT_CMD)))
  735. {
  736. bOOBESwitch = TRUE;
  737. break; // Stop processing command line, launch oobe
  738. }
  739. }
  740. if (lstrcmpi(&szOut[0],OEMCODE_CMD)==0)
  741. {
  742. GetCmdLineToken(&szCmdLine,szOut);
  743. if (szOut[0])
  744. {
  745. ZeroMemory(g_szOemCode,sizeof(g_szOemCode));
  746. if(GetFilteredCmdLineToken(&szCmdLine,g_szOemCode))
  747. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_OEMCODE_FROM_CMDLINE;
  748. }
  749. }
  750. if (lstrcmpi(&szOut[0],PRODCODE_CMD)==0)
  751. {
  752. GetCmdLineToken(&szCmdLine,szOut);
  753. if (szOut[0])
  754. {
  755. ZeroMemory(g_szProductCode,sizeof(g_szProductCode));
  756. if(GetFilteredCmdLineToken(&szCmdLine,g_szProductCode))
  757. {
  758. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_PRODCODE_FROM_CMDLINE;
  759. //Is it for sbs???
  760. if (!lstrcmpi(g_szProductCode, PRODCODE_SBS))
  761. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_SBS;
  762. }
  763. }
  764. }
  765. if (0 == lstrcmpi(szOut,PROMO_CMD))
  766. {
  767. GetCmdLineToken(&szCmdLine,szOut);
  768. if (szOut[0])
  769. {
  770. ZeroMemory(g_szPromoCode,sizeof(g_szPromoCode));
  771. if(GetFilteredCmdLineToken(&szCmdLine,g_szPromoCode))
  772. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_PROMOCODE_FROM_CMDLINE;
  773. }
  774. }
  775. if (0 == lstrcmpi(szOut,SKIPINTRO_CMD))
  776. {
  777. g_bSkipIntro = TRUE;
  778. }
  779. if (0 == lstrcmpi(szOut,SMARTREBOOT_CMD))
  780. {
  781. GetCmdLineToken(&szCmdLine,szOut);
  782. if (GetFilteredCmdLineToken(&szCmdLine,szOut))
  783. {
  784. g_bNewIspPath = FALSE;
  785. if (0 == lstrcmpi(szOut, NEWISP_SR))
  786. g_bNewIspPath = TRUE;
  787. if (0 == lstrcmpi(szOut, AUTO_SR))
  788. g_bAutoConfigPath = TRUE;
  789. if (0 == lstrcmpi(szOut, MANUAL_SR))
  790. g_bManualPath = TRUE;
  791. if (0 == lstrcmpi(szOut, LAN_SR))
  792. g_bLanPath = TRUE;
  793. }
  794. }
  795. //
  796. // Check for the smart start command line switch
  797. //
  798. if (0 == lstrcmpi(szOut,SMARTSTART_CMD))
  799. {
  800. //
  801. // If we shouldn't be running, quit.
  802. //
  803. if (SMART_QUITICW == MyIsSmartStartEx(NULL, 0))
  804. {
  805. // Set completed key if SmartStart is already configured
  806. SetICWComplete();
  807. // Set the welcome show bit
  808. UpdateWelcomeRegSetting(TRUE);
  809. return FALSE; // Bail out of ICWCONN1.EXE
  810. }
  811. }
  812. //
  813. // 5/21/97 jmazner Olympus #4157
  814. // usage: /shellnext c:\path\executeable [parameters]
  815. // the token following nextapp will be shellExec'd at the
  816. // end of the "current" path. It can be anything that the shell
  817. // knows how to handle -- an .exe, a URL, etc.. If executable
  818. // name contains white space (eg: c:\program files\foo.exe), it
  819. // should be wrapped in double quotes, "c:\program files\foo.exe"
  820. // This will cause us to treat it as a single token.
  821. //
  822. // all consecutive subsequent tokens will
  823. // be passed to ShellExec as the parameters until a token is
  824. // encountered of the form /<non-slash character>. That is to say,
  825. // the TCHARacter combination // will be treated as an escape character
  826. //
  827. // this is easiest to explain by way of examples.
  828. //
  829. // examples of usage:
  830. //
  831. // icwconn1.exe /shellnext "C:\prog files\wordpad.exe" file.txt
  832. // icwconn1.exe /prod IE /shellnext msimn.exe /promo MCI
  833. // icwconn1.exe /shellnext msimn.exe //START_MAIL /promo MCI
  834. //
  835. // the executeable string and parameter string are limited to
  836. // a length of MAX_PATH
  837. //
  838. GetShellNextToken(szOut, szCmdLine);
  839. #ifdef DEBUG
  840. if (lstrcmpi(szOut, ICON_CMD)==0)
  841. {
  842. DoDesktopChanges(hInstance);
  843. return(FALSE);
  844. }
  845. #endif //DEBUG
  846. // If there is a /desktop command line arg, then do the
  847. // processing and bail
  848. if (lstrcmpi(szOut, UPDATEDESKTOP_CMD)==0)
  849. {
  850. if(g_bUserIsAdmin && !g_bUserIsIEAKRestricted)
  851. UpdateDesktop(hInstance);
  852. return(FALSE);
  853. }
  854. // If there is a /restoredesktop command line arg, then do the
  855. // processing and bail
  856. if (lstrcmpi(szOut, RESTOREDESKTOP_CMD)==0)
  857. {
  858. UndoDesktopChanges(hInstance);
  859. return(FALSE);
  860. }
  861. //Do we need to go into IEAK mode?
  862. if (lstrcmpi(szOut, ICW_IEAK_CMD)==0)
  863. {
  864. TCHAR szIEAKFlag [2] = TEXT("\0");
  865. TCHAR szIEAKStr [MAX_PATH*2] = TEXT("\0");
  866. TCHAR szBrandHTML [MAX_PATH*2] = TEXT("\0");
  867. TCHAR szBrandHeadBMP [MAX_PATH*2] = TEXT("\0");
  868. TCHAR szBrandWaterBMP [MAX_PATH*2] = TEXT("\0");
  869. TCHAR szIEAKBillHtm [MAX_PATH*2] = TEXT("\0");
  870. TCHAR szIEAKPayCsv [MAX_PATH*2] = TEXT("\0");
  871. TCHAR szDefIspName [MAX_PATH] = TEXT("\0");
  872. TCHAR szDrive [_MAX_DRIVE] = TEXT("\0");
  873. TCHAR szDir [_MAX_DIR] = TEXT("\0");
  874. TCHAR szDefaultTitle [MAX_PATH*2] = TEXT("\0");
  875. gpWizardState->cmnStateData.lpfnConfigSys = &ConfigureSystem;
  876. GetCmdLineToken(&szCmdLine,szOut); //get rid of the space
  877. if(GetFilteredCmdLineToken(&szCmdLine,szOut))
  878. {
  879. //Get the path to the isp file
  880. lstrcpyn(gpWizardState->cmnStateData.ispInfo.szISPFile,
  881. szOut + 1,
  882. lstrlen(szOut) -1);
  883. //get the branding settings as well...
  884. //The HTML page
  885. GetPrivateProfileString(ICW_IEAK_SECTION, ICW_IEAK_HTML,
  886. TEXT(""), szBrandHTML,
  887. ARRAYSIZE(szBrandHTML),
  888. gpWizardState->cmnStateData.ispInfo.szISPFile);
  889. //The wizard title
  890. lstrcpy(szDefaultTitle, gpWizardState->cmnStateData.szWizTitle);
  891. GetPrivateProfileString(ICW_IEAK_SECTION, ICW_IEAK_TITLE, szDefaultTitle,
  892. gpWizardState->cmnStateData.szWizTitle, ARRAYSIZE(gpWizardState->cmnStateData.szWizTitle),
  893. gpWizardState->cmnStateData.ispInfo.szISPFile);
  894. //The header bitmap
  895. GetPrivateProfileString(ICW_IEAK_SECTION, ICW_IEAK_HEADER_BMP, TEXT(""),
  896. szBrandHeadBMP, ARRAYSIZE(szBrandHeadBMP),
  897. gpWizardState->cmnStateData.ispInfo.szISPFile);
  898. //The watermark bitmap
  899. GetPrivateProfileString(ICW_IEAK_SECTION, ICW_IEAK_WATERMARK_BMP, TEXT(""),
  900. szBrandWaterBMP, ARRAYSIZE(szBrandWaterBMP),
  901. gpWizardState->cmnStateData.ispInfo.szISPFile);
  902. _tsplitpath(gpWizardState->cmnStateData.ispInfo.szISPFile,
  903. szDrive,
  904. szDir,
  905. NULL,
  906. NULL);
  907. _tmakepath(g_szBrandedHTML, szDrive, szDir, szBrandHTML, NULL);
  908. _tmakepath(g_szBrandedHeaderBMP, szDrive, szDir, szBrandHeadBMP, NULL);
  909. _tmakepath(g_szBrandedWatermarkBMP, szDrive, szDir, szBrandWaterBMP, NULL);
  910. //make sure file is valid if not bail
  911. if (ValidateFile(g_szBrandedHTML))
  912. {
  913. //evertyething is cool.. let's set the right flags.
  914. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_IEAKMODE | ICW_CFGFLAG_BRANDED;
  915. //Look in the isp file and see if they provided an ISP name to display
  916. //for dialing and whatnot
  917. //If we can't find this section we'll just use a resource which says
  918. //"an Internet service provider"
  919. LoadString(hInstance, IDS_DEFAULT_ISPNAME, szDefIspName, ARRAYSIZE(szDefIspName));
  920. GetPrivateProfileString(ICW_IEAK_SECTION, ICW_IEAK_ISPNAME, szDefIspName,
  921. szIEAKStr, ARRAYSIZE(szIEAKStr),
  922. gpWizardState->cmnStateData.ispInfo.szISPFile);
  923. if (lstrlen(szIEAKStr) == 0)
  924. lstrcpy(szIEAKStr, szDefIspName);
  925. lstrcpy(gpWizardState->cmnStateData.ispInfo.szISPName, szIEAKStr);
  926. //Look in the isp file and see if they want UserInfo
  927. //If we can't find this section it the isp file we'll assume "no".
  928. GetPrivateProfileString(ICW_IEAK_SECTION, ICW_IEAK_USERINFO, TEXT("0"),
  929. szIEAKFlag, ARRAYSIZE(szIEAKFlag),
  930. gpWizardState->cmnStateData.ispInfo.szISPFile);
  931. if ((BOOL)_ttoi(szIEAKFlag))
  932. {
  933. // Since we are showing the user info page, we may need to
  934. // show or hide the company name
  935. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_USERINFO;
  936. if (GetPrivateProfileInt(ICW_IEAK_SECTION,
  937. ICW_IEAK_USECOMPANYNAME,
  938. 0,
  939. gpWizardState->cmnStateData.ispInfo.szISPFile))
  940. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_USE_COMPANYNAME;
  941. }
  942. //Look in the isp file and see if they want billing stuff
  943. //If we can't find this section it the isp file we'll assume "no".
  944. GetPrivateProfileString(ICW_IEAK_SECTION, ICW_IEAK_BILLING, TEXT("0"),
  945. szIEAKFlag, ARRAYSIZE(szIEAKFlag),
  946. gpWizardState->cmnStateData.ispInfo.szISPFile);
  947. if ((BOOL)_ttoi(szIEAKFlag))
  948. {
  949. //try and get the billing page, if it's not there don't bother
  950. //setting the bit.
  951. GetPrivateProfileString(ICW_IEAK_SECTION, ICW_IEAK_BILLINGHTM, NULL,
  952. szIEAKBillHtm, ARRAYSIZE(szIEAKBillHtm),
  953. gpWizardState->cmnStateData.ispInfo.szISPFile);
  954. if(lstrlen(szIEAKBillHtm) != 0)
  955. {
  956. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_BILL;
  957. lstrcpy(gpWizardState->cmnStateData.ispInfo.szBillHtm, szIEAKBillHtm);
  958. }
  959. }
  960. //Look in the isp file and see if they want payment stuff
  961. //If we can't find this section it the isp file we'll assume "no".
  962. GetPrivateProfileString(ICW_IEAK_SECTION, ICW_IEAK_PAYMENT, NULL,
  963. szIEAKFlag, ARRAYSIZE(szIEAKFlag),
  964. gpWizardState->cmnStateData.ispInfo.szISPFile);
  965. if ((BOOL)_ttoi(szIEAKFlag))
  966. {
  967. //try and get the payment csv, if it's not there don't bother
  968. //setting the bit.
  969. GetPrivateProfileString(ICW_IEAK_SECTION, ICW_IEAK_PAYMENTCSV, NULL,
  970. szIEAKPayCsv, ARRAYSIZE(szIEAKPayCsv),
  971. gpWizardState->cmnStateData.ispInfo.szISPFile);
  972. if (lstrlen(szIEAKPayCsv) != 0)
  973. {
  974. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_PAYMENT;
  975. lstrcpy(gpWizardState->cmnStateData.ispInfo.szPayCsv, szIEAKPayCsv);
  976. }
  977. }
  978. //Get validation flags from the ISP file
  979. gpWizardState->cmnStateData.ispInfo.dwValidationFlags = GetPrivateProfileInt(ICW_IEAK_SECTION,
  980. ICW_IEAK_VALIDATEFLAGS,
  981. 0xFFFFFFFF,
  982. gpWizardState->cmnStateData.ispInfo.szISPFile);
  983. }
  984. }
  985. }
  986. // Check to see if we are running in Branded mode. In this mode, we will allow special
  987. // OEM tweaks.
  988. if (lstrcmpi(szOut, BRANDED_CMD)==0)
  989. {
  990. TCHAR szCurrentDir[MAX_PATH] = TEXT("\0");
  991. //whether or not the ICW "fails" to run in branding mode we do not wan to overide the alloffers value
  992. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_DO_NOT_OVERRIDE_ALLOFFERS;
  993. GetCurrentDirectory(ARRAYSIZE(szCurrentDir), szCurrentDir);
  994. wsprintf (g_szBrandedHTML, TEXT("%s\\%s"), szCurrentDir, BRANDING_DEFAULT_HTML);
  995. wsprintf (g_szBrandedHeaderBMP, TEXT("%s\\%s"), szCurrentDir, BRANDING_DEFAULT_HEADER_BMP);
  996. wsprintf (g_szBrandedWatermarkBMP, TEXT("%s\\%s"), szCurrentDir, BRANDING_DEFAULT_WATERMARK_BMP);
  997. // We are in OEM mode, so see if we allow branding
  998. if (bCheckForOEMBranding())
  999. {
  1000. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_BRANDED;
  1001. }
  1002. }
  1003. // Check to see if we are running in run once mode. In this mode, we will disallow IE check box
  1004. if (0 == lstrcmpi(szOut, RUNONCE_CMD))
  1005. {
  1006. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_DO_NOT_OVERRIDE_ALLOFFERS;
  1007. g_bRunOnce = TRUE;
  1008. }
  1009. // Check to see if we were run from a shortcut on the desktop
  1010. if (0 == lstrcmpi(szOut, SHORTCUTENTRY_CMD))
  1011. {
  1012. gpWizardState->cmnStateData.dwFlags |= ICW_CFGFLAG_DO_NOT_OVERRIDE_ALLOFFERS;
  1013. g_bShortcutEntry = TRUE;
  1014. }
  1015. // Check to see if we should debug the OEMCUST.INI file
  1016. if (0 == lstrcmpi(szOut, DEBUG_OEMCUSTOM))
  1017. {
  1018. g_bDebugOEMCustomization = TRUE;
  1019. }
  1020. // Eat the next token, it will be null if we are at the end
  1021. GetCmdLineToken(&szCmdLine,szOut);
  1022. }
  1023. g_OEMOOBE = g_OEMOOBE && bOOBESwitch;
  1024. gpWizardState->cmnStateData.bOEMEntryPt = g_bShortcutEntry || g_bRunOnce;
  1025. return(TRUE);
  1026. }
  1027. //+----------------------------------------------------------------------------
  1028. //
  1029. // Function: RemoveShellNextFromReg
  1030. //
  1031. // Synopsis: deletes the ShellNext reg key if present. This key is set by
  1032. // SetShellNext in inetcfg.dll in conjunction with
  1033. // CheckConnectionWizard.
  1034. //
  1035. // Arguments: none
  1036. //
  1037. // Returns: none
  1038. //
  1039. // History: jmazner 7/9/97 Olympus #9170
  1040. //
  1041. //-----------------------------------------------------------------------------
  1042. void RemoveShellNextFromReg( void )
  1043. {
  1044. HKEY hkey;
  1045. if ((RegOpenKey(HKEY_CURRENT_USER, ICWSETTINGSPATH, &hkey)) == ERROR_SUCCESS)
  1046. {
  1047. RegDeleteValue(hkey, TEXT("ShellNext"));
  1048. RegCloseKey(hkey);
  1049. }
  1050. }
  1051. //+----------------------------------------------------------------------------
  1052. //
  1053. // Function: GetShellNextFromReg
  1054. //
  1055. // Synopsis: Reads the ShellNext key from the registry, and then parses it
  1056. // into a command and parameter. This key is set by
  1057. // SetShellNext in inetcfg.dll in conjunction with
  1058. // CheckConnectionWizard.
  1059. //
  1060. // Arguments: none
  1061. //
  1062. // Returns: none
  1063. //
  1064. // History: jmazner 7/9/97 Olympus #9170
  1065. //
  1066. //-----------------------------------------------------------------------------
  1067. BOOL GetShellNextFromReg
  1068. (
  1069. LPTSTR lpszCommand,
  1070. LPTSTR lpszParams
  1071. )
  1072. {
  1073. BOOL fRet = TRUE;
  1074. TCHAR szShellNextCmd [MAX_PATH] = TEXT("\0");
  1075. DWORD dwShellNextSize = sizeof(szShellNextCmd);
  1076. LPTSTR lpszTemp = NULL;
  1077. HKEY hkey = NULL;
  1078. if( !lpszCommand || !lpszParams )
  1079. {
  1080. return FALSE;
  1081. }
  1082. if ((RegOpenKey(HKEY_CURRENT_USER, ICWSETTINGSPATH, &hkey)) == ERROR_SUCCESS)
  1083. {
  1084. if (RegQueryValueEx(hkey,
  1085. TEXT("ShellNext"),
  1086. NULL,
  1087. NULL,
  1088. (BYTE *)szShellNextCmd,
  1089. (DWORD *)&dwShellNextSize) != ERROR_SUCCESS)
  1090. {
  1091. fRet = FALSE;
  1092. goto GetShellNextFromRegExit;
  1093. }
  1094. }
  1095. else
  1096. {
  1097. fRet = FALSE;
  1098. goto GetShellNextFromRegExit;
  1099. }
  1100. //
  1101. // This call will parse the first token into lpszCommand, and set szShellNextCmd
  1102. // to point to the remaining tokens (these will be the parameters). Need to use
  1103. // the pszTemp var because GetCmdLineToken changes the pointer's value, and we
  1104. // need to preserve lpszShellNextCmd's value so that we can GlobalFree it later.
  1105. //
  1106. lpszTemp = szShellNextCmd;
  1107. GetCmdLineToken( &lpszTemp, lpszCommand );
  1108. lstrcpy( lpszParams, lpszTemp );
  1109. //
  1110. // it's possible that the shellNext command was wrapped in quotes for
  1111. // parsing purposes. But since ShellExec doesn't understand quotes,
  1112. // we now need to remove them.
  1113. //
  1114. if( '"' == lpszCommand[0] )
  1115. {
  1116. //
  1117. // get rid of the first quote
  1118. // note that we're shifting the entire string beyond the first quote
  1119. // plus the terminating NULL down by one byte.
  1120. //
  1121. memmove( lpszCommand, &(lpszCommand[1]), lstrlen(lpszCommand) );
  1122. //
  1123. // now get rid of the last quote
  1124. //
  1125. lpszCommand[lstrlen(lpszCommand) - 1] = '\0';
  1126. }
  1127. GetShellNextFromRegExit:
  1128. if (hkey)
  1129. RegCloseKey(hkey);
  1130. return fRet;
  1131. }
  1132. void StartIE
  1133. (
  1134. LPTSTR lpszURL
  1135. )
  1136. {
  1137. TCHAR szIEPath[MAX_PATH];
  1138. HKEY hkey;
  1139. // first get the app path
  1140. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  1141. REGSTR_PATH_APPPATHS,
  1142. 0,
  1143. KEY_READ,
  1144. &hkey) == ERROR_SUCCESS)
  1145. {
  1146. DWORD dwTmp = sizeof(szIEPath);
  1147. if(RegQueryValue(hkey, TEXT("iexplore.exe"), szIEPath, (PLONG)&dwTmp) != ERROR_SUCCESS)
  1148. {
  1149. ShellExecute(NULL,TEXT("open"),szIEPath,lpszURL,NULL,SW_NORMAL);
  1150. }
  1151. else
  1152. {
  1153. ShellExecute(NULL,TEXT("open"),TEXT("iexplore.exe"),lpszURL,NULL,SW_NORMAL);
  1154. }
  1155. RegCloseKey(hkey);
  1156. }
  1157. else
  1158. {
  1159. ShellExecute(NULL,TEXT("open"),TEXT("iexplore.exe"),lpszURL,NULL,SW_NORMAL);
  1160. }
  1161. }
  1162. void HandleShellNext
  1163. (
  1164. void
  1165. )
  1166. {
  1167. DWORD dwVal = 0;
  1168. DWORD dwSize = sizeof(dwVal);
  1169. HKEY hKey = NULL;
  1170. if(RegOpenKeyEx(HKEY_CURRENT_USER,
  1171. ICWSETTINGSPATH,
  1172. 0,
  1173. KEY_ALL_ACCESS,
  1174. &hKey) == ERROR_SUCCESS)
  1175. {
  1176. RegQueryValueEx(hKey,
  1177. ICW_REGKEYCOMPLETED,
  1178. 0,
  1179. NULL,
  1180. (LPBYTE)&dwVal,
  1181. &dwSize);
  1182. RegCloseKey(hKey);
  1183. }
  1184. if (dwVal)
  1185. {
  1186. if (PathIsURL(g_szShellNext) || g_bRunDefaultHtm)
  1187. StartIE(g_szShellNext);
  1188. else if(g_szShellNext[0] != '\0')
  1189. // Let the shell deal with it
  1190. ShellExecute(NULL,TEXT("open"),g_szShellNext,g_szShellNextParams,NULL,SW_NORMAL);
  1191. }
  1192. }
  1193. extern "C" void _stdcall ModuleEntry (void)
  1194. {
  1195. int i;
  1196. g_hMapping = CreateFileMapping( INVALID_HANDLE_VALUE,
  1197. NULL,
  1198. PAGE_READONLY,
  1199. 0,
  1200. 32,
  1201. #ifdef ICWDEBUG
  1202. TEXT("ICWDEBUG") );
  1203. #else
  1204. TEXT("ICWCONN1") );
  1205. #endif //ICWDEBUG
  1206. if(g_hMapping)
  1207. {
  1208. // See if there is allready a mapping file, if so, we have an instance
  1209. // already running
  1210. if( GetLastError() == ERROR_ALREADY_EXISTS )
  1211. {
  1212. // Front the existing instance, and exit
  1213. HWND hWnd = NULL;
  1214. HWND FirstChildhWnd = NULL;
  1215. TCHAR szTitle[MAX_TITLE] = TEXT("\0");
  1216. if (!LoadString(g_hInstance, IDS_APPNAME, szTitle, ARRAYSIZE(szTitle)))
  1217. lstrcpy(szTitle, TEXT("Internet Connection Wizard"));
  1218. if (hWnd = FindWindow(TEXT("#32770"), szTitle))
  1219. {
  1220. FirstChildhWnd = GetLastActivePopup(hWnd);
  1221. SetForegroundWindow(hWnd); // bring main window to top
  1222. // is a pop-up window active
  1223. if (hWnd != FirstChildhWnd)
  1224. BringWindowToTop(FirstChildhWnd);
  1225. }
  1226. CloseHandle(g_hMapping);
  1227. ExitProcess(1);
  1228. }
  1229. else
  1230. {
  1231. LPTSTR pszCmdLine = GetCommandLine();
  1232. // We don't want the "No disk in drive X:" requesters, so we set
  1233. // the critical error mask such that calls will just silently fail
  1234. SetErrorMode(SEM_FAILCRITICALERRORS);
  1235. if ( *pszCmdLine == TEXT('\"') )
  1236. {
  1237. /*
  1238. * Scan, and skip over, subsequent characters until
  1239. * another double-quote or a null is encountered.
  1240. */
  1241. while ( *++pszCmdLine && (*pszCmdLine != TEXT('\"')) )
  1242. ;
  1243. /*
  1244. * If we stopped on a double-quote (usual case), skip
  1245. * over it.
  1246. */
  1247. if ( *pszCmdLine == TEXT('\"') )
  1248. pszCmdLine++;
  1249. }
  1250. else
  1251. {
  1252. while (*pszCmdLine > TEXT(' '))
  1253. pszCmdLine++;
  1254. }
  1255. /*
  1256. * Skip past any white space preceeding the second token.
  1257. */
  1258. while (*pszCmdLine && (*pszCmdLine <= TEXT(' ')))
  1259. {
  1260. pszCmdLine++;
  1261. }
  1262. // Set the current directory.
  1263. HKEY hkey = NULL;
  1264. TCHAR szAppPathKey[MAX_PATH];
  1265. TCHAR szICWPath[MAX_PATH];
  1266. DWORD dwcbPath = sizeof(szICWPath);
  1267. lstrcpy (szAppPathKey, REGSTR_PATH_APPPATHS);
  1268. lstrcat (szAppPathKey, TEXT("\\"));
  1269. lstrcat (szAppPathKey, TEXT("ICWCONN1.EXE"));
  1270. if ((RegOpenKeyEx(HKEY_LOCAL_MACHINE,szAppPathKey, 0, KEY_QUERY_VALUE, &hkey)) == ERROR_SUCCESS)
  1271. {
  1272. if (RegQueryValueEx(hkey, TEXT("Path"), NULL, NULL, (BYTE *)szICWPath, (DWORD *)&dwcbPath) == ERROR_SUCCESS)
  1273. {
  1274. // The Apppaths' have a trailing semicolon that we need to get rid of
  1275. // dwcbPath is the lenght of the string including the NULL terminator
  1276. int nSize = lstrlen(szICWPath);
  1277. szICWPath[nSize-1] = TEXT('\0');
  1278. SetCurrentDirectory(szICWPath);
  1279. }
  1280. }
  1281. if (hkey)
  1282. RegCloseKey(hkey);
  1283. i = WinMainT(GetModuleHandle(NULL), NULL, pszCmdLine, SW_SHOWDEFAULT);
  1284. // see if we need to exectute any /ShellNext dudes
  1285. HandleShellNext();
  1286. CloseHandle(g_hMapping);
  1287. ExitProcess(i); // Were outa here....
  1288. }
  1289. }
  1290. else
  1291. {
  1292. ExitProcess(1);
  1293. }
  1294. } /* ModuleEntry() */
  1295. /*******************************************************************
  1296. NAME: InitWizardState
  1297. SYNOPSIS: Initializes wizard state structure
  1298. ********************************************************************/
  1299. BOOL InitWizardState(WIZARDSTATE * pWizardState)
  1300. {
  1301. HRESULT hr;
  1302. ASSERT(pWizardState);
  1303. // set starting page
  1304. #ifdef ICWDEBUG
  1305. pWizardState->uCurrentPage = ORD_PAGE_ICWDEBUG_OFFER;
  1306. #else //!def ICWDEBUG
  1307. pWizardState->uCurrentPage = ORD_PAGE_INTRO;
  1308. #endif //ICWDEBUG
  1309. pWizardState->fNeedReboot = FALSE;
  1310. pWizardState->bDoUserPick = FALSE;
  1311. gpWizardState->lSelectedPhoneNumber = -1;
  1312. gpWizardState->lDefaultLocationID = -1;
  1313. gpWizardState->lLocationID = -1;
  1314. #ifndef ICWDEBUG
  1315. //init the tutor app class
  1316. g_pICWTutorApp = new CICWTutorApp;
  1317. #endif //ICWDEBUG
  1318. // Instansiate ICWHELP objects
  1319. hr = CoCreateInstance(CLSID_TapiLocationInfo,NULL,CLSCTX_INPROC_SERVER,
  1320. IID_ITapiLocationInfo,(LPVOID *)&pWizardState->pTapiLocationInfo);
  1321. if (FAILED(hr))
  1322. return FALSE;
  1323. hr = CoCreateInstance(CLSID_RefDial,NULL,CLSCTX_INPROC_SERVER,
  1324. IID_IRefDial,(LPVOID *)&pWizardState->pRefDial);
  1325. if (FAILED(hr))
  1326. return FALSE;
  1327. hr = CoCreateInstance(CLSID_ICWSystemConfig,NULL,CLSCTX_INPROC_SERVER,
  1328. IID_IICWSystemConfig,(LPVOID *)&pWizardState->cmnStateData.pICWSystemConfig);
  1329. if (FAILED(hr))
  1330. return FALSE;
  1331. hr = CoCreateInstance(CLSID_INSHandler,NULL,CLSCTX_INPROC_SERVER,
  1332. IID_IINSHandler,(LPVOID *)&pWizardState->pINSHandler);
  1333. if (FAILED(hr))
  1334. return FALSE;
  1335. if ( !(SUCCEEDED(hr) ||
  1336. !pWizardState->pTapiLocationInfo ||
  1337. !pWizardState->cmnStateData.pICWSystemConfig ||
  1338. !pWizardState->pRefDial ||
  1339. !pWizardState->pINSHandler ))
  1340. {
  1341. return FALSE;
  1342. }
  1343. // Need to load the UTIL lib, to register the WEBOC window class
  1344. pWizardState->hInstUtilDLL = LoadLibrary(ICW_UTIL);
  1345. gpWizardState->cmnStateData.lpfnCompleteOLS = &OlsFinish;
  1346. gpWizardState->cmnStateData.bOEMOffline = FALSE;
  1347. gpWizardState->cmnStateData.lpfnFillWindowWithAppBackground = &FillWindowWithAppBackground;
  1348. gpWizardState->cmnStateData.ispInfo.bFailedIns = FALSE;
  1349. return TRUE;
  1350. }
  1351. /*******************************************************************
  1352. NAME: InitWizardState
  1353. SYNOPSIS: Initializes wizard state structure
  1354. ********************************************************************/
  1355. BOOL CleanupWizardState(WIZARDSTATE * pWizardState)
  1356. {
  1357. ASSERT(pWizardState);
  1358. #ifndef ICWDEBUG
  1359. ASSERT(g_pICWTutorApp);
  1360. delete g_pICWTutorApp;
  1361. #endif //ICWDEBUG
  1362. // Clean up allocated bitmaps that might exist from the branding case
  1363. if (gpWizardState->cmnStateData.hbmWatermark)
  1364. DeleteObject(gpWizardState->cmnStateData.hbmWatermark);
  1365. gpWizardState->cmnStateData.hbmWatermark = NULL;
  1366. if (pWizardState->pTapiLocationInfo)
  1367. {
  1368. pWizardState->pTapiLocationInfo->Release();
  1369. pWizardState->pTapiLocationInfo = NULL;
  1370. }
  1371. if (pWizardState->pRefDial)
  1372. {
  1373. pWizardState->pRefDial->Release();
  1374. pWizardState->pRefDial = NULL;
  1375. }
  1376. if (pWizardState->pINSHandler)
  1377. {
  1378. pWizardState->pINSHandler->Release();
  1379. pWizardState->pINSHandler = NULL;
  1380. }
  1381. if (pWizardState->cmnStateData.pICWSystemConfig)
  1382. {
  1383. pWizardState->cmnStateData.pICWSystemConfig->Release();
  1384. pWizardState->cmnStateData.pICWSystemConfig = NULL;
  1385. }
  1386. if(pWizardState->pHTMLWalker)
  1387. {
  1388. pWizardState->pHTMLWalker->Release();
  1389. pWizardState->pHTMLWalker = NULL;
  1390. }
  1391. if(pWizardState->pICWWebView)
  1392. {
  1393. pWizardState->pICWWebView->Release();
  1394. pWizardState->pICWWebView = NULL;
  1395. }
  1396. if (pWizardState->hInstUtilDLL)
  1397. FreeLibrary(pWizardState->hInstUtilDLL);
  1398. //Now's a good a time as any, let's clean up the
  1399. //download directory
  1400. RemoveDownloadDirectory();
  1401. #ifdef ICWDEBUG
  1402. RemoveTempOfferDirectory();
  1403. #endif
  1404. return TRUE;
  1405. }
  1406. LRESULT FAR PASCAL WndSubClassFunc
  1407. (
  1408. HWND hWnd,
  1409. WORD uMsg,
  1410. WPARAM wParam,
  1411. LPARAM lParam
  1412. )
  1413. {
  1414. switch (uMsg)
  1415. {
  1416. case WM_ERASEBKGND:
  1417. return 1;
  1418. case PSM_SETWIZBUTTONS:
  1419. g_pICWApp->SetWizButtons(hWnd, lParam);
  1420. break;
  1421. case PSM_CANCELTOCLOSE:
  1422. // Disable the cancel button.
  1423. g_pICWApp->m_BtnCancel.Enable(FALSE);
  1424. break;
  1425. case PSM_SETHEADERTITLE:
  1426. SendMessage(g_pICWApp->m_hWndApp, WUM_SETTITLE, 0, lParam);
  1427. break;
  1428. default:
  1429. return CallWindowProc(g_lpfnOldWndProc, hWnd, uMsg, wParam, lParam);
  1430. }
  1431. return TRUE;
  1432. }
  1433. /**************************************************************************
  1434. PropSheetCallback()
  1435. **************************************************************************/
  1436. void CALLBACK PropSheetCallback(HWND hwndPropSheet, UINT uMsg, LPARAM lParam)
  1437. {
  1438. switch(uMsg)
  1439. {
  1440. //called before the dialog is created, hwndPropSheet = NULL, lParam points to dialog resource
  1441. case PSCB_PRECREATE:
  1442. {
  1443. LPDLGTEMPLATE lpTemplate = (LPDLGTEMPLATE)lParam;
  1444. // THIS is the STYLE used for Wizards.
  1445. // We want to nuke all of these styles to remove the border, caption,
  1446. // etc., and make the wizard a child of the parent. We also make the
  1447. // wizard not visible initially. It will be make visable after
  1448. // we get the wizard modeless handle back and do some resizing.
  1449. //STYLE DS_MODALFRAME | DS_3DLOOK | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION | WS_SYSMENU
  1450. lpTemplate->style &= ~(WS_SYSMENU | WS_CAPTION | DS_CONTEXTHELP | DS_3DLOOK | DS_MODALFRAME | WS_POPUP | WS_VISIBLE);
  1451. lpTemplate->style |= WS_CHILD;
  1452. break;
  1453. }
  1454. //called after the dialog is created
  1455. case PSCB_INITIALIZED:
  1456. //
  1457. // Now subclass the Wizard window AND the DLG class so all of our
  1458. // dialog pages can be transparent
  1459. //
  1460. g_lpfnOldWndProc = (WNDPROC)SetWindowLongPtr(hwndPropSheet, GWLP_WNDPROC, (DWORD_PTR)&WndSubClassFunc);
  1461. break;
  1462. }
  1463. }
  1464. // General ICW cleanup to be done before existing
  1465. void ICWCleanup (void)
  1466. {
  1467. if (gpICWCONNApprentice)
  1468. {
  1469. gpICWCONNApprentice->Release();
  1470. gpICWCONNApprentice = NULL;
  1471. }
  1472. if (gpINETCFGApprentice)
  1473. {
  1474. gpINETCFGApprentice->Release();
  1475. gpINETCFGApprentice = NULL;
  1476. }
  1477. if( g_pdwDialogIDList )
  1478. {
  1479. GlobalFree(g_pdwDialogIDList);
  1480. g_pdwDialogIDList = NULL;
  1481. }
  1482. if( g_pCICWExtension )
  1483. {
  1484. g_pCICWExtension->Release();
  1485. g_pCICWExtension = NULL;
  1486. }
  1487. if( g_pCINETCFGExtension )
  1488. {
  1489. g_pCINETCFGExtension->Release();
  1490. g_pCINETCFGExtension = NULL;
  1491. }
  1492. CleanupWizardState(gpWizardState);
  1493. }
  1494. /*******************************************************************
  1495. NAME: RunSignupWizard
  1496. SYNOPSIS: Creates property sheet pages, initializes wizard property sheet and runs wizard
  1497. ENTRY:
  1498. EXIT: returns TRUE if user runs wizard to completion,
  1499. FALSE if user cancels or an error occurs
  1500. NOTES: Wizard pages all use one dialog proc (GenDlgProc).
  1501. They may specify their own handler procs to get called
  1502. at init time or in response to Next, Cancel or a dialog
  1503. control, or use the default behavior of GenDlgProc.
  1504. ********************************************************************/
  1505. HWND RunSignupWizard(HWND hWndOwner)
  1506. {
  1507. HPROPSHEETPAGE hWizPage[EXE_NUM_WIZARD_PAGES]; // array to hold handles to pages
  1508. PROPSHEETPAGE psPage; // struct used to create prop sheet pages
  1509. PROPSHEETHEADER psHeader; // struct used to run wizard property sheet
  1510. UINT nPageIndex;
  1511. INT_PTR iRet;
  1512. BOOL bUse256ColorBmp = FALSE;
  1513. HBITMAP hbmHeader = NULL;
  1514. ASSERT(gpWizardState); // assert that global structs have been allocated
  1515. AllocDialogIDList();
  1516. // Compute the color depth we are running in
  1517. HDC hdc = GetDC(NULL);
  1518. if(hdc)
  1519. {
  1520. if(GetDeviceCaps(hdc,BITSPIXEL) >= 8)
  1521. bUse256ColorBmp = TRUE;
  1522. ReleaseDC(NULL, hdc);
  1523. }
  1524. // zero out structures
  1525. ZeroMemory(&hWizPage,sizeof(hWizPage)); // hWizPage is an array
  1526. ZeroMemory(&psPage,sizeof(PROPSHEETPAGE));
  1527. ZeroMemory(&psHeader,sizeof(PROPSHEETHEADER));
  1528. // fill out common data property sheet page struct
  1529. psPage.dwSize = sizeof(PROPSHEETPAGE);
  1530. psPage.hInstance = g_hInstance;
  1531. psPage.pfnDlgProc = GenDlgProc;
  1532. // create a property sheet page for each page in the wizard
  1533. for (nPageIndex = 0;nPageIndex < EXE_NUM_WIZARD_PAGES;nPageIndex++)
  1534. {
  1535. psPage.dwFlags = PSP_DEFAULT | PSP_USETITLE;
  1536. psPage.pszTitle = gpWizardState->cmnStateData.szWizTitle;
  1537. psPage.pszTemplate = MAKEINTRESOURCE(PageInfo[nPageIndex].uDlgID);
  1538. // set a pointer to the PAGEINFO struct as the private data for this page
  1539. psPage.lParam = (LPARAM) &PageInfo[nPageIndex];
  1540. if (!gpWizardState->cmnStateData.bOEMCustom)
  1541. {
  1542. if (PageInfo[nPageIndex].nIdTitle)
  1543. {
  1544. psPage.dwFlags |= PSP_USEHEADERTITLE | (PageInfo[nPageIndex].nIdSubTitle ? PSP_USEHEADERSUBTITLE : 0);
  1545. psPage.pszHeaderTitle = MAKEINTRESOURCE(PageInfo[nPageIndex].nIdTitle);
  1546. psPage.pszHeaderSubTitle = MAKEINTRESOURCE(PageInfo[nPageIndex].nIdSubTitle);
  1547. }
  1548. else
  1549. {
  1550. psPage.dwFlags |= PSP_HIDEHEADER;
  1551. }
  1552. }
  1553. hWizPage[nPageIndex] = CreatePropertySheetPage(&psPage);
  1554. if (!hWizPage[nPageIndex])
  1555. {
  1556. ASSERT(0);
  1557. // creating page failed, free any pages already created and bail
  1558. MsgBox(NULL,IDS_ERR_OUTOFMEMORY,MB_ICONEXCLAMATION,MB_OK);
  1559. UINT nFreeIndex;
  1560. for (nFreeIndex=0;nFreeIndex<nPageIndex;nFreeIndex++)
  1561. DestroyPropertySheetPage(hWizPage[nFreeIndex]);
  1562. iRet = 0;
  1563. goto RunSignupWizardExit;
  1564. }
  1565. // Load the accelerator table for this page if necessary
  1566. if (PageInfo[nPageIndex].idAccel)
  1567. PageInfo[nPageIndex].hAccel = LoadAccelerators(g_hInstance,
  1568. MAKEINTRESOURCE(PageInfo[nPageIndex].idAccel));
  1569. }
  1570. // fill out property sheet header struct
  1571. psHeader.dwSize = sizeof(psHeader);
  1572. if (!gpWizardState->cmnStateData.bOEMCustom)
  1573. {
  1574. psHeader.dwFlags = PSH_WIZARD | PSH_WIZARD97 | PSH_WATERMARK | PSH_HEADER | PSH_STRETCHWATERMARK;
  1575. }
  1576. else
  1577. {
  1578. psHeader.dwFlags = PSH_WIZARD | PSH_MODELESS | PSH_USECALLBACK;
  1579. psHeader.pfnCallback = (PFNPROPSHEETCALLBACK)PropSheetCallback;
  1580. }
  1581. psHeader.hwndParent = hWndOwner;
  1582. psHeader.hInstance = g_hInstance;
  1583. psHeader.nPages = EXE_NUM_WIZARD_PAGES;
  1584. psHeader.phpage = hWizPage;
  1585. #ifndef ICWDEBUG
  1586. // If we are running in Modal mode, then we want to setup for
  1587. // wizard 97 style with appropriate bitmaps
  1588. if (!gpWizardState->cmnStateData.bOEMCustom)
  1589. {
  1590. if (gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_BRANDED)
  1591. {
  1592. psHeader.nStartPage = ORD_PAGE_BRANDEDINTRO;
  1593. if (NULL == (gpWizardState->cmnStateData.hbmWatermark = LoadBrandedBitmap(BRANDED_WATERMARK)))
  1594. {
  1595. // Use our default Watermark
  1596. gpWizardState->cmnStateData.hbmWatermark = (HBITMAP)LoadImage(g_hInstance,
  1597. bUse256ColorBmp ? MAKEINTRESOURCE(IDB_WATERMARK256):MAKEINTRESOURCE(IDB_WATERMARK16),
  1598. IMAGE_BITMAP,
  1599. 0,
  1600. 0,
  1601. LR_CREATEDIBSECTION);
  1602. }
  1603. if(NULL != (hbmHeader = LoadBrandedBitmap(BRANDED_HEADER)))
  1604. {
  1605. psHeader.hbmHeader = hbmHeader;
  1606. psHeader.dwFlags |= PSH_USEHBMHEADER;
  1607. }
  1608. else
  1609. {
  1610. // Use our default header
  1611. psHeader.pszbmHeader = bUse256ColorBmp?
  1612. MAKEINTRESOURCE(IDB_BANNER256):
  1613. MAKEINTRESOURCE(IDB_BANNER16);
  1614. }
  1615. }
  1616. else // NORMAL
  1617. {
  1618. if (gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAG_SBS)
  1619. psHeader.nStartPage = ORD_PAGE_SBSINTRO;
  1620. else
  1621. psHeader.nStartPage = ORD_PAGE_INTRO;
  1622. // Specify wizard left graphic
  1623. gpWizardState->cmnStateData.hbmWatermark = (HBITMAP)LoadImage(g_hInstance,
  1624. bUse256ColorBmp ? MAKEINTRESOURCE(IDB_WATERMARK256):MAKEINTRESOURCE(IDB_WATERMARK16),
  1625. IMAGE_BITMAP,
  1626. 0,
  1627. 0,
  1628. LR_CREATEDIBSECTION);
  1629. // Specify wizard header
  1630. psHeader.pszbmHeader = bUse256ColorBmp?MAKEINTRESOURCE(IDB_BANNER256):MAKEINTRESOURCE(IDB_BANNER16);
  1631. }
  1632. }
  1633. else
  1634. {
  1635. // Start page for modeless is INTRO2
  1636. psHeader.nStartPage = ORD_PAGE_INTRO2;
  1637. }
  1638. #else //ifdef ICWDEBUG
  1639. psHeader.nStartPage = ORD_PAGE_ICWDEBUG_OFFER;
  1640. // Specify wizard left graphic
  1641. gpWizardState->cmnStateData.hbmWatermark = (HBITMAP)LoadImage(g_hInstance,
  1642. bUse256ColorBmp ? MAKEINTRESOURCE(IDB_WATERMARK256):MAKEINTRESOURCE(IDB_WATERMARK16),
  1643. IMAGE_BITMAP,
  1644. 0,
  1645. 0,
  1646. LR_CREATEDIBSECTION);
  1647. psHeader.pszbmHeader = bUse256ColorBmp?MAKEINTRESOURCE(IDB_BANNER256) :MAKEINTRESOURCE(IDB_BANNER16);
  1648. #endif // ICWDEBUG
  1649. //
  1650. // set state of gpWizardState->fNeedReboot and
  1651. // reset the state of Backup Flag here - MKarki Bug #404
  1652. //
  1653. if (gfBackedUp == TRUE)
  1654. {
  1655. gpWizardState->fNeedReboot = gfReboot;
  1656. gfBackedUp = FALSE;
  1657. }
  1658. //register the Native font control so the dialog won't fail
  1659. INITCOMMONCONTROLSEX iccex;
  1660. iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  1661. iccex.dwICC = ICC_NATIVEFNTCTL_CLASS;
  1662. if (!InitCommonControlsEx(&iccex))
  1663. return FALSE;
  1664. // run the Wizard
  1665. iRet = PropertySheet(&psHeader);
  1666. // If we are doing a modless wizard, then PropertySheet will return
  1667. // immediatly with the property sheet window handle
  1668. if (gpWizardState->cmnStateData.bOEMCustom)
  1669. return (HWND)iRet;
  1670. if (iRet < 0)
  1671. {
  1672. // property sheet failed, most likely due to lack of memory
  1673. MsgBox(NULL,IDS_ERR_OUTOFMEMORY,MB_ICONEXCLAMATION,MB_OK);
  1674. }
  1675. RunSignupWizardExit:
  1676. // Clean up allocated bitmaps that might exist from the branding case
  1677. if (gpWizardState->cmnStateData.hbmWatermark)
  1678. DeleteObject(gpWizardState->cmnStateData.hbmWatermark);
  1679. gpWizardState->cmnStateData.hbmWatermark = NULL;
  1680. if (hbmHeader)
  1681. DeleteObject(hbmHeader);
  1682. return (HWND)(iRet > 0);
  1683. }
  1684. // Convert a string color in HTML format (#RRGGBB) into a COLORREF
  1685. COLORREF ColorToRGB
  1686. (
  1687. LPTSTR lpszColor
  1688. )
  1689. {
  1690. int r,g,b;
  1691. Assert(lpszColor);
  1692. if (lpszColor && '#' == lpszColor[0])
  1693. {
  1694. _stscanf(lpszColor, TEXT("#%2x%2x%2x"), &r,&g,&b);
  1695. return RGB(r,g,b);
  1696. }
  1697. return RGB(0,0,0);
  1698. }
  1699. const TCHAR cszSectionGeneral[] = TEXT("General");
  1700. const TCHAR cszSectionHeader[] = TEXT("Header");
  1701. const TCHAR cszSectionDialog[] = TEXT("Dialog");
  1702. const TCHAR cszSectionBusy[] = TEXT("Busy");
  1703. const TCHAR cszSectionBack[] = TEXT("Back");
  1704. const TCHAR cszSectionNext[] = TEXT("Next");
  1705. const TCHAR cszSectionFinish[] = TEXT("Finish");
  1706. const TCHAR cszSectionCancel[] = TEXT("Cancel");
  1707. const TCHAR cszSectionTutorial[] = TEXT("Tutorial");
  1708. const TCHAR cszTitleBar[] = TEXT("TitleBar");
  1709. const TCHAR cszBackgroundBmp[] = TEXT("background");
  1710. const TCHAR cszFirstPageHTML[] = TEXT("FirstPageHTML");
  1711. const TCHAR cszFirstPageBackground[] = TEXT("FirstPageBackground");
  1712. const TCHAR cszTop[] = TEXT("Top");
  1713. const TCHAR cszLeft[] = TEXT("Left");
  1714. const TCHAR cszBackgroundColor[] = TEXT("BackgroundColor");
  1715. const TCHAR cszAnimation[] = TEXT("Animation");
  1716. const TCHAR cszFontFace[] = TEXT("FontFace");
  1717. const TCHAR cszFontSize[] = TEXT("FontSize");
  1718. const TCHAR cszFontWeight[] = TEXT("FontWeight");
  1719. const TCHAR cszFontColor[] = TEXT("FontColor");
  1720. const TCHAR cszPressedBmp[] = TEXT("PressedBmp");
  1721. const TCHAR cszUnpressedBmp[] = TEXT("UnpressedBmp");
  1722. const TCHAR cszTransparentColor[] = TEXT("TransparentColor");
  1723. const TCHAR cszDisabledColor[] = TEXT("DisabledColor");
  1724. const TCHAR cszvalign[] = TEXT("valign");
  1725. const TCHAR cszTutorialExe[] = TEXT("TutorialExe");
  1726. const TCHAR cszTutorialHTML[] = TEXT("TutorialHTML");
  1727. #define DEFAULT_HEADER_FONT TEXT("MS Shell Dlg")
  1728. #define DEFAULT_HEADER_SIZE 8
  1729. #define DEFAULT_HEADER_WEIGHT FW_BOLD
  1730. void DisplayOEMCustomizationErrorMsg
  1731. (
  1732. int iErrorCode
  1733. )
  1734. {
  1735. TCHAR szMsg[MAX_RES_LEN];
  1736. TCHAR szFmt[MAX_RES_LEN];
  1737. TCHAR szMsgText[MAX_RES_LEN];
  1738. TCHAR szTitle[MAX_RES_LEN];
  1739. LoadString(g_hInstance, OEMCUSTOM_ERR_MSGFMT, szFmt, ARRAYSIZE(szFmt));
  1740. LoadString(g_hInstance, iErrorCode, szMsgText, ARRAYSIZE(szMsgText));
  1741. LoadString(g_hInstance, IDS_APPNAME, szTitle, ARRAYSIZE(szTitle));
  1742. wsprintf (szMsg, szFmt, szMsgText);
  1743. MessageBox(NULL, szMsg, szTitle, MB_OK | MB_ICONSTOP);
  1744. }
  1745. // Check for, and load OEM custom settings.
  1746. BOOL bCheckOEMCustomization
  1747. (
  1748. void
  1749. )
  1750. {
  1751. int iErrorCode = 0;
  1752. TCHAR szTemp[MAX_PATH];
  1753. TCHAR szOEMCustPath[MAX_PATH];
  1754. TCHAR szOEMCustFile[MAX_PATH];
  1755. TCHAR szHTMLFile[MAX_PATH];
  1756. TCHAR szCurrentDir[MAX_PATH];
  1757. TCHAR szPressedBmp[MAX_PATH];
  1758. TCHAR szUnpressedBmp[MAX_PATH];
  1759. TCHAR szFontFace[MAX_PATH];
  1760. TCHAR szColor[MAX_COLOR_NAME];
  1761. TCHAR szTransparentColor[MAX_COLOR_NAME];
  1762. TCHAR szDisabledColor[MAX_COLOR_NAME];
  1763. TCHAR szBusyFile[MAX_PATH];
  1764. COLORREF clrDisabled;
  1765. long lFontSize;
  1766. long lFontWeight;
  1767. long xPos;
  1768. int i;
  1769. int iVal;
  1770. int iTitleTop, iTitleLeft;
  1771. long vAlign;
  1772. const LPTSTR cszBtnSections[4] = { (LPTSTR)cszSectionBack,
  1773. (LPTSTR)cszSectionNext,
  1774. (LPTSTR)cszSectionFinish,
  1775. (LPTSTR)cszSectionCancel};
  1776. CICWButton *Btnids[4] = { &g_pICWApp->m_BtnBack,
  1777. &g_pICWApp->m_BtnNext,
  1778. &g_pICWApp->m_BtnFinish,
  1779. &g_pICWApp->m_BtnCancel};
  1780. Assert(g_pICWApp);
  1781. // We only allow OEM customization when running from Runonce or
  1782. // a desktop shortcut
  1783. if (!g_bRunOnce && !g_bShortcutEntry)
  1784. {
  1785. iErrorCode = OEMCUSTOM_ERR_NOTOEMENTRY;
  1786. goto CheckOEMCustomizationExit2;
  1787. }
  1788. // Get the current working directory so we can restore it later
  1789. if (!GetCurrentDirectory(ARRAYSIZE(szCurrentDir), szCurrentDir))
  1790. {
  1791. iErrorCode = OEMCUSTOM_ERR_WINAPI;
  1792. goto CheckOEMCustomizationExit2;
  1793. }
  1794. szCurrentDir[MAX_PATH-1] = TEXT('\0');
  1795. // Get the Windows Directory. That is the root where the OEM customization
  1796. // files will be places
  1797. if (!GetWindowsDirectory(szOEMCustPath, ARRAYSIZE(szOEMCustPath)))
  1798. {
  1799. iErrorCode = OEMCUSTOM_ERR_WINAPI;
  1800. goto CheckOEMCustomizationExit2;
  1801. }
  1802. szOEMCustPath[MAX_PATH-1] = TEXT('\0');
  1803. // Make sure we can append the backslash and oem customization file name
  1804. if ((int)(sizeof(szOEMCustFile) - lstrlen(szOEMCustPath)) <
  1805. (int) (3 + lstrlen(c_szOEMCustomizationDir) + lstrlen(c_szOEMCustomizationFile)))
  1806. {
  1807. iErrorCode = OEMCUSTOM_ERR_NOMEM;
  1808. goto CheckOEMCustomizationExit2;
  1809. }
  1810. // Append the customization file name
  1811. lstrcat(szOEMCustPath, TEXT("\\"));
  1812. lstrcat(szOEMCustPath, c_szOEMCustomizationDir);
  1813. // Change the working directory to the OEM one
  1814. SetCurrentDirectory(szOEMCustPath);
  1815. lstrcpy(szOEMCustFile, szOEMCustPath);
  1816. lstrcat(szOEMCustFile, TEXT("\\"));
  1817. lstrcat(szOEMCustFile, c_szOEMCustomizationFile);
  1818. // See if the customization file exists.
  1819. if (0xFFFFFFFF == GetFileAttributes(szOEMCustFile))
  1820. {
  1821. iErrorCode = OEMCUSTOM_ERR_CANNOTFINDOEMCUSTINI;
  1822. goto CheckOEMCustomizationExit;
  1823. }
  1824. // Background bitmap
  1825. GetPrivateProfileString(cszSectionGeneral,
  1826. cszBackgroundBmp,
  1827. TEXT(""),
  1828. szTemp,
  1829. ARRAYSIZE(szTemp),
  1830. szOEMCustFile);
  1831. if (FAILED(g_pICWApp->SetBackgroundBitmap(szTemp)))
  1832. {
  1833. iErrorCode = OEMCUSTOM_ERR_BACKGROUND;
  1834. goto CheckOEMCustomizationExit;
  1835. }
  1836. // solid background color for some HTML pages
  1837. GetPrivateProfileString(cszSectionDialog,
  1838. cszBackgroundColor,
  1839. TEXT(""),
  1840. gpWizardState->cmnStateData.szHTMLBackgroundColor,
  1841. ARRAYSIZE(gpWizardState->cmnStateData.szHTMLBackgroundColor),
  1842. szOEMCustFile);
  1843. // App Title
  1844. if (!GetPrivateProfileString(cszSectionGeneral,
  1845. cszTitleBar,
  1846. TEXT(""),
  1847. g_pICWApp->m_szAppTitle,
  1848. ARRAYSIZE(g_pICWApp->m_szAppTitle),
  1849. szOEMCustFile))
  1850. {
  1851. // Default Title
  1852. LoadString(g_hInstance, IDS_APPNAME, g_pICWApp->m_szAppTitle, ARRAYSIZE(g_pICWApp->m_szAppTitle));
  1853. }
  1854. else
  1855. {
  1856. if (0 == lstrcmpi(g_pICWApp->m_szAppTitle, ICW_NO_APP_TITLE))
  1857. LoadString(g_hInstance, IDS_APPNAME, g_pICWApp->m_szAppTitle, ARRAYSIZE(g_pICWApp->m_szAppTitle));
  1858. }
  1859. // Initial HTML page. REQUIRED
  1860. if (!GetPrivateProfileString(cszSectionGeneral,
  1861. cszFirstPageHTML,
  1862. TEXT(""),
  1863. szHTMLFile,
  1864. ARRAYSIZE(szHTMLFile),
  1865. szOEMCustFile))
  1866. {
  1867. iErrorCode = OEMCUSTOM_ERR_FIRSTHTML;
  1868. goto CheckOEMCustomizationExit;
  1869. }
  1870. // Make sure the file exists
  1871. if (0xFFFFFFFF == GetFileAttributes(szHTMLFile))
  1872. {
  1873. iErrorCode = OEMCUSTOM_ERR_FIRSTHTML;
  1874. goto CheckOEMCustomizationExit;
  1875. }
  1876. // Form the URL for the OEM first page HTML
  1877. wsprintf(g_pICWApp->m_szOEMHTML, TEXT("FILE://%s\\%s"), szOEMCustPath, szHTMLFile);
  1878. // Initial page. BMP (OPTIONAL). NOTE this bitmap must be loaded after
  1879. // the main background bitmap
  1880. if (GetPrivateProfileString(cszSectionGeneral,
  1881. cszFirstPageBackground,
  1882. TEXT(""),
  1883. szTemp,
  1884. ARRAYSIZE(szTemp),
  1885. szOEMCustFile))
  1886. {
  1887. if (FAILED(g_pICWApp->SetFirstPageBackgroundBitmap(szTemp)))
  1888. {
  1889. iErrorCode = OEMCUSTOM_ERR_BACKGROUND;
  1890. goto CheckOEMCustomizationExit;
  1891. }
  1892. }
  1893. // Position, and AVI file for busy animation
  1894. if (GetPrivateProfileString(cszSectionBusy,
  1895. cszAnimation,
  1896. TEXT(""),
  1897. szBusyFile,
  1898. ARRAYSIZE(szBusyFile),
  1899. szOEMCustFile))
  1900. {
  1901. if (0 != lstrcmpi(szBusyFile, TEXT("off")))
  1902. {
  1903. // A file is specified, so quality the path
  1904. if (!GetCurrentDirectory(ARRAYSIZE(gpWizardState->cmnStateData.szBusyAnimationFile),
  1905. gpWizardState->cmnStateData.szBusyAnimationFile))
  1906. {
  1907. iErrorCode = OEMCUSTOM_ERR_WINAPI;
  1908. goto CheckOEMCustomizationExit;
  1909. }
  1910. gpWizardState->cmnStateData.szBusyAnimationFile[MAX_PATH-1] = TEXT('\0');
  1911. // Make sure we can append the backslash and 8.3 file name
  1912. if ((int)(sizeof(gpWizardState->cmnStateData.szBusyAnimationFile) -
  1913. lstrlen(gpWizardState->cmnStateData.szBusyAnimationFile)) <
  1914. (int) (2 + lstrlen(gpWizardState->cmnStateData.szBusyAnimationFile)))
  1915. {
  1916. iErrorCode = OEMCUSTOM_ERR_NOMEM;
  1917. goto CheckOEMCustomizationExit;
  1918. }
  1919. // Append the customization file name
  1920. lstrcat(gpWizardState->cmnStateData.szBusyAnimationFile, TEXT("\\"));
  1921. lstrcat(gpWizardState->cmnStateData.szBusyAnimationFile, szBusyFile);
  1922. }
  1923. else
  1924. {
  1925. // Hide the animation
  1926. gpWizardState->cmnStateData.bHideProgressAnime = TRUE;
  1927. }
  1928. }
  1929. gpWizardState->cmnStateData.xPosBusy = GetPrivateProfileInt(cszSectionBusy,
  1930. cszLeft,
  1931. -1,
  1932. szOEMCustFile);
  1933. // Get the background color for the Animation file
  1934. if (GetPrivateProfileString(cszSectionBusy,
  1935. cszBackgroundColor,
  1936. TEXT(""),
  1937. szColor,
  1938. ARRAYSIZE(szColor),
  1939. szOEMCustFile))
  1940. {
  1941. g_pICWApp->m_clrBusyBkGnd = ColorToRGB(szColor);
  1942. }
  1943. // Get the font to be used for the Titles. Note this must be done
  1944. // after the background bitmap is set, since the title position
  1945. // is dependant on the overall window size
  1946. GetPrivateProfileString(cszSectionHeader,
  1947. cszFontFace,
  1948. DEFAULT_HEADER_FONT,
  1949. szFontFace,
  1950. ARRAYSIZE(szFontFace),
  1951. szOEMCustFile);
  1952. GetPrivateProfileString(cszSectionHeader,
  1953. cszFontColor,
  1954. TEXT(""),
  1955. szColor,
  1956. ARRAYSIZE(szColor),
  1957. szOEMCustFile);
  1958. lFontSize = (long)GetPrivateProfileInt(cszSectionHeader,
  1959. cszFontSize,
  1960. DEFAULT_HEADER_SIZE,
  1961. szOEMCustFile);
  1962. lFontWeight = (long)GetPrivateProfileInt(cszSectionHeader,
  1963. cszFontWeight,
  1964. DEFAULT_HEADER_WEIGHT,
  1965. szOEMCustFile);
  1966. iTitleTop = GetPrivateProfileInt(cszSectionHeader,
  1967. cszTop,
  1968. -1,
  1969. szOEMCustFile);
  1970. iTitleLeft = GetPrivateProfileInt(cszSectionHeader,
  1971. cszLeft,
  1972. -1,
  1973. szOEMCustFile);
  1974. if (FAILED(g_pICWApp->SetTitleParams(iTitleTop,
  1975. iTitleLeft,
  1976. szFontFace,
  1977. lFontSize,
  1978. lFontWeight,
  1979. ColorToRGB(szColor))))
  1980. {
  1981. iErrorCode = OEMCUSTOM_ERR_HEADERPARAMS;
  1982. goto CheckOEMCustomizationExit;
  1983. }
  1984. // Get the Button Params
  1985. for (i = 0; i < ARRAYSIZE(cszBtnSections); i++)
  1986. {
  1987. GetPrivateProfileString(cszBtnSections[i],
  1988. cszPressedBmp,
  1989. TEXT(""),
  1990. szPressedBmp,
  1991. ARRAYSIZE(szPressedBmp),
  1992. szOEMCustFile);
  1993. GetPrivateProfileString(cszBtnSections[i],
  1994. cszUnpressedBmp,
  1995. TEXT(""),
  1996. szUnpressedBmp,
  1997. ARRAYSIZE(szUnpressedBmp),
  1998. szOEMCustFile);
  1999. if (!GetPrivateProfileString(cszBtnSections[i],
  2000. cszFontFace,
  2001. TEXT(""),
  2002. szFontFace,
  2003. ARRAYSIZE(szFontFace),
  2004. szOEMCustFile))
  2005. {
  2006. iErrorCode = OEMCUSTOM_ERR_NOBUTTONFONTFACE;
  2007. goto CheckOEMCustomizationExit;
  2008. }
  2009. xPos = (long)GetPrivateProfileInt(cszBtnSections[i],
  2010. cszLeft,
  2011. -1,
  2012. szOEMCustFile);
  2013. if (-1 == xPos)
  2014. {
  2015. iErrorCode = OEMCUSTOM_ERR_NOBUTTONLEFT;
  2016. goto CheckOEMCustomizationExit;
  2017. }
  2018. lFontSize = (long)GetPrivateProfileInt(cszBtnSections[i],
  2019. cszFontSize,
  2020. -1,
  2021. szOEMCustFile);
  2022. if (-1 == lFontSize)
  2023. {
  2024. iErrorCode = OEMCUSTOM_ERR_NOBUTTONFONTSIZE;
  2025. goto CheckOEMCustomizationExit;
  2026. }
  2027. lFontWeight = (long)GetPrivateProfileInt(cszBtnSections[i],
  2028. cszFontWeight,
  2029. 0,
  2030. szOEMCustFile);
  2031. GetPrivateProfileString(cszBtnSections[i],
  2032. cszFontColor,
  2033. TEXT(""),
  2034. szColor,
  2035. ARRAYSIZE(szColor),
  2036. szOEMCustFile);
  2037. if (!GetPrivateProfileString(cszBtnSections[i],
  2038. cszTransparentColor,
  2039. TEXT(""),
  2040. szTransparentColor,
  2041. ARRAYSIZE(szTransparentColor),
  2042. szOEMCustFile))
  2043. {
  2044. iErrorCode = OEMCUSTOM_ERR_NOBUTTONTRANSPARENTCOLOR;
  2045. goto CheckOEMCustomizationExit;
  2046. }
  2047. if (GetPrivateProfileString(cszBtnSections[i],
  2048. cszDisabledColor,
  2049. TEXT(""),
  2050. szDisabledColor,
  2051. ARRAYSIZE(szDisabledColor),
  2052. szOEMCustFile))
  2053. clrDisabled = ColorToRGB(szDisabledColor);
  2054. else
  2055. clrDisabled = GetSysColor(COLOR_GRAYTEXT);
  2056. // Vertical alignment for the text
  2057. if (GetPrivateProfileString(cszBtnSections[i],
  2058. cszvalign,
  2059. TEXT(""),
  2060. szTemp,
  2061. ARRAYSIZE(szTemp),
  2062. szOEMCustFile))
  2063. {
  2064. if (0 == lstrcmpi(szTemp, TEXT("top")))
  2065. vAlign = DT_TOP;
  2066. else if (0 == lstrcmpi(szTemp, TEXT("center")))
  2067. vAlign = DT_VCENTER;
  2068. else if (0 == lstrcmpi(szTemp, TEXT("bottom")))
  2069. vAlign = DT_BOTTOM;
  2070. else
  2071. vAlign = -1;
  2072. }
  2073. else
  2074. {
  2075. vAlign = -1;
  2076. }
  2077. if (FAILED(Btnids[i]->SetButtonParams(xPos,
  2078. szPressedBmp,
  2079. szUnpressedBmp,
  2080. szFontFace,
  2081. lFontSize,
  2082. lFontWeight,
  2083. ColorToRGB(szColor),
  2084. ColorToRGB(szTransparentColor),
  2085. clrDisabled,
  2086. vAlign)))
  2087. {
  2088. iErrorCode = OEMCUSTOM_ERR_BUTTONPARAMS;
  2089. goto CheckOEMCustomizationExit;
  2090. }
  2091. }
  2092. // Handle the Tutorial button seperatly, because they might
  2093. // not want one
  2094. if (GetPrivateProfileString(cszSectionTutorial,
  2095. cszPressedBmp,
  2096. TEXT(""),
  2097. szPressedBmp,
  2098. ARRAYSIZE(szPressedBmp),
  2099. szOEMCustFile))
  2100. {
  2101. GetPrivateProfileString(cszSectionTutorial,
  2102. cszUnpressedBmp,
  2103. TEXT(""),
  2104. szUnpressedBmp,
  2105. ARRAYSIZE(szUnpressedBmp),
  2106. szOEMCustFile);
  2107. if (!GetPrivateProfileString(cszSectionTutorial,
  2108. cszFontFace,
  2109. TEXT(""),
  2110. szFontFace,
  2111. ARRAYSIZE(szFontFace),
  2112. szOEMCustFile))
  2113. {
  2114. iErrorCode = OEMCUSTOM_ERR_NOBUTTONFONTFACE;
  2115. goto CheckOEMCustomizationExit;
  2116. }
  2117. xPos = (long)GetPrivateProfileInt(cszSectionTutorial,
  2118. cszLeft,
  2119. -1,
  2120. szOEMCustFile);
  2121. if (-1 == xPos)
  2122. {
  2123. iErrorCode = OEMCUSTOM_ERR_NOBUTTONLEFT;
  2124. goto CheckOEMCustomizationExit;
  2125. }
  2126. lFontSize = (long)GetPrivateProfileInt(cszSectionTutorial,
  2127. cszFontSize,
  2128. -1,
  2129. szOEMCustFile);
  2130. if (-1 == lFontSize)
  2131. {
  2132. iErrorCode = OEMCUSTOM_ERR_NOBUTTONFONTSIZE;
  2133. goto CheckOEMCustomizationExit;
  2134. }
  2135. lFontWeight = (long)GetPrivateProfileInt(cszSectionTutorial,
  2136. cszFontWeight,
  2137. 0,
  2138. szOEMCustFile);
  2139. GetPrivateProfileString(cszSectionTutorial,
  2140. cszFontColor,
  2141. TEXT(""),
  2142. szColor,
  2143. ARRAYSIZE(szColor),
  2144. szOEMCustFile);
  2145. if (!GetPrivateProfileString(cszSectionTutorial,
  2146. cszTransparentColor,
  2147. TEXT(""),
  2148. szTransparentColor,
  2149. ARRAYSIZE(szTransparentColor),
  2150. szOEMCustFile))
  2151. {
  2152. iErrorCode = OEMCUSTOM_ERR_NOBUTTONTRANSPARENTCOLOR;
  2153. goto CheckOEMCustomizationExit;
  2154. }
  2155. if (GetPrivateProfileString(cszSectionTutorial,
  2156. cszDisabledColor,
  2157. TEXT(""),
  2158. szDisabledColor,
  2159. ARRAYSIZE(szDisabledColor),
  2160. szOEMCustFile))
  2161. clrDisabled = ColorToRGB(szDisabledColor);
  2162. else
  2163. clrDisabled = GetSysColor(COLOR_GRAYTEXT);
  2164. // Vertical alignment for the text
  2165. if (GetPrivateProfileString(cszSectionTutorial,
  2166. cszvalign,
  2167. TEXT(""),
  2168. szTemp,
  2169. ARRAYSIZE(szTemp),
  2170. szOEMCustFile))
  2171. {
  2172. if (0 == lstrcmpi(szTemp, TEXT("top")))
  2173. vAlign = DT_TOP;
  2174. else if (0 == lstrcmpi(szTemp, TEXT("center")))
  2175. vAlign = DT_VCENTER;
  2176. else if (0 == lstrcmpi(szTemp, TEXT("bottom")))
  2177. vAlign = DT_BOTTOM;
  2178. else
  2179. vAlign = -1;
  2180. }
  2181. else
  2182. {
  2183. vAlign = -1;
  2184. }
  2185. if (FAILED(g_pICWApp->m_BtnTutorial.SetButtonParams(xPos,
  2186. szPressedBmp,
  2187. szUnpressedBmp,
  2188. szFontFace,
  2189. lFontSize,
  2190. lFontWeight,
  2191. ColorToRGB(szColor),
  2192. ColorToRGB(szTransparentColor),
  2193. clrDisabled,
  2194. vAlign)))
  2195. {
  2196. iErrorCode = OEMCUSTOM_ERR_BUTTONPARAMS;
  2197. goto CheckOEMCustomizationExit;
  2198. }
  2199. #ifndef ICWDEBUG
  2200. // See if the OEM wants to replace the Tutor executable
  2201. if (GetPrivateProfileString(cszSectionTutorial,
  2202. cszTutorialExe,
  2203. TEXT(""),
  2204. szTemp,
  2205. ARRAYSIZE(szTemp),
  2206. szOEMCustFile))
  2207. {
  2208. // Checkt to see if the provided name is fully qualified or not. If it
  2209. // is not fully qualified, then make szTemp a fully qualified path using
  2210. // the OEM custom file dir as the base path
  2211. if (PathIsFileSpec(szTemp))
  2212. {
  2213. TCHAR szDrive [_MAX_DRIVE] = TEXT("\0");
  2214. TCHAR szDir [_MAX_DIR] = TEXT("\0");
  2215. TCHAR szFile [MAX_PATH] = TEXT("\0"); // Large because there might be cmd line params
  2216. // Breakdown the current OEM custom file path
  2217. _tsplitpath(szOEMCustFile,
  2218. szDrive,
  2219. szDir,
  2220. NULL,
  2221. NULL);
  2222. // The name specified in the OEMCUST.INI file is the file name
  2223. lstrcpyn(szFile, szTemp, ARRAYSIZE(szFile));
  2224. // Form the fill path into szTemp
  2225. _tmakepath(szTemp, szDrive, szDir, szFile, NULL);
  2226. }
  2227. g_pICWTutorApp->ReplaceTutorAppCmdLine(szTemp);
  2228. }
  2229. // See if the OEM wants to replace the Tutor HTML
  2230. else if (GetPrivateProfileString(cszSectionTutorial,
  2231. cszTutorialHTML,
  2232. TEXT(""),
  2233. szTemp,
  2234. ARRAYSIZE(szTemp),
  2235. szOEMCustFile))
  2236. {
  2237. TCHAR szCmdLine[MAX_PATH];
  2238. wsprintf(szCmdLine, TEXT("icwtutor %s\\%s"), szOEMCustPath, szTemp);
  2239. g_pICWTutorApp->ReplaceTutorAppCmdLine(szCmdLine);
  2240. }
  2241. #endif
  2242. }
  2243. else
  2244. {
  2245. // Don't show the tutorial button
  2246. g_pICWApp->m_BtnTutorial.SetButtonDisplay(FALSE);
  2247. }
  2248. // This makes sure things will fit. This function will compute the button
  2249. // area height based on overall window size, set by the background bitmap
  2250. if (-1 == g_pICWApp->GetButtonAreaHeight())
  2251. {
  2252. iErrorCode = OEMCUSTOM_ERR_SIZE;
  2253. goto CheckOEMCustomizationExit;
  2254. }
  2255. // Get the Top Left corner of the ICW wizard page frame. Note this has be be
  2256. // done after the button area is calculated
  2257. iVal = GetPrivateProfileInt(cszSectionDialog,
  2258. cszTop,
  2259. -1,
  2260. szOEMCustFile);
  2261. if (FAILED(g_pICWApp->SetWizardWindowTop(iVal)))
  2262. {
  2263. iErrorCode = OEMCUSTOM_ERR_WIZARDTOP;
  2264. goto CheckOEMCustomizationExit;
  2265. }
  2266. iVal = GetPrivateProfileInt(cszSectionDialog,
  2267. cszLeft,
  2268. -1,
  2269. szOEMCustFile);
  2270. if (FAILED(g_pICWApp->SetWizardWindowLeft(iVal)))
  2271. {
  2272. iErrorCode = OEMCUSTOM_ERR_WIZARDLEFT;
  2273. goto CheckOEMCustomizationExit;
  2274. }
  2275. if (GetPrivateProfileString(cszSectionDialog,
  2276. cszFontColor,
  2277. TEXT(""),
  2278. szColor,
  2279. ARRAYSIZE(szColor),
  2280. szOEMCustFile))
  2281. {
  2282. lstrcpy(gpWizardState->cmnStateData.szclrHTMLText, szColor);
  2283. gpWizardState->cmnStateData.clrText = ColorToRGB(szColor);
  2284. }
  2285. else
  2286. {
  2287. lstrcpy(gpWizardState->cmnStateData.szclrHTMLText, TEXT("WINDOWTEXT"));
  2288. gpWizardState->cmnStateData.clrText = GetSysColor(COLOR_WINDOWTEXT);
  2289. }
  2290. CheckOEMCustomizationExit:
  2291. // Change the working directory back, and perform any other cleanup
  2292. SetCurrentDirectory(szCurrentDir);
  2293. CheckOEMCustomizationExit2:
  2294. // if there was an error see if we should show the reason
  2295. if (iErrorCode)
  2296. {
  2297. if (g_bDebugOEMCustomization)
  2298. DisplayOEMCustomizationErrorMsg(iErrorCode);
  2299. return FALSE;
  2300. }
  2301. else
  2302. {
  2303. return TRUE;
  2304. }
  2305. }
  2306. BOOL TranslateWizardPageAccelerator
  2307. (
  2308. HWND hWndWizPage,
  2309. LPMSG lpMsg
  2310. )
  2311. {
  2312. // Locate the accelerator table for the current page
  2313. PAGEINFO *pPageInfo = (PAGEINFO *) GetWindowLongPtr(hWndWizPage,DWLP_USER);
  2314. BOOL bRet = FALSE;
  2315. if (pPageInfo)
  2316. {
  2317. // See if there is a nested accelerator
  2318. if (pPageInfo->hAccelNested)
  2319. bRet = TranslateAccelerator(g_pICWApp->m_hWndApp, pPageInfo->hAccelNested, lpMsg);
  2320. // If no nested, or nested not translated, then check for accelerators on the page
  2321. if (!bRet && pPageInfo->hAccel)
  2322. bRet = TranslateAccelerator(g_pICWApp->m_hWndApp, pPageInfo->hAccel, lpMsg);
  2323. }
  2324. else
  2325. bRet = FALSE;
  2326. return bRet;
  2327. }
  2328. /*******************************************************************
  2329. NAME: RunSignupApp
  2330. SYNOPSIS: Create an application to host the Wizard pages
  2331. ENTRY:
  2332. EXIT: returns TRUE if user runs ICW to completion,
  2333. FALSE if user cancels or an error occurs
  2334. NOTES: Wizard pages all use one dialog proc (GenDlgProc).
  2335. They may specify their own handler procs to get called
  2336. at init time or in response to Next, Cancel or a dialog
  2337. control, or use the default behavior of GenDlgProc.
  2338. ********************************************************************/
  2339. BOOL RunSignupApp(void)
  2340. {
  2341. MSG msg;
  2342. // Initialize the Application Class
  2343. if (S_OK != g_pICWApp->Initialize())
  2344. return FALSE;
  2345. // Start the message loop.
  2346. while (GetMessage(&msg, (HWND) NULL, 0, 0))
  2347. {
  2348. // If the wizard pages are being displayed, we need to see
  2349. // if the wizard is ready to be destroyed.
  2350. // (PropSheet_GetCurrentPageHwnd returns NULL) then destroy the dialog.
  2351. // PropSheet_GetCurrentPageHwnd will return NULL after the OK or Cancel
  2352. // button has been pressed and all of the pages have been notified.
  2353. if(gpWizardState->cmnStateData.hWndWizardPages && (NULL == PropSheet_GetCurrentPageHwnd(gpWizardState->cmnStateData.hWndWizardPages)))
  2354. {
  2355. DestroyWindow(gpWizardState->cmnStateData.hWndWizardPages);
  2356. gpWizardState->cmnStateData.hWndWizardPages = NULL;
  2357. DestroyWindow(g_pICWApp->m_hWndApp);
  2358. }
  2359. if(gpWizardState->cmnStateData.hWndWizardPages)
  2360. {
  2361. // Need to translate accelerators for this page. The page accelerators need
  2362. // to be translated first, because some of the app level ones overlap, but
  2363. // not visible at the same time. For this reason we want the page to have first
  2364. // shot at translating.
  2365. if (!TranslateWizardPageAccelerator(PropSheet_GetCurrentPageHwnd(gpWizardState->cmnStateData.hWndWizardPages), &msg))
  2366. {
  2367. // OK see if the app has any accelerators
  2368. if (!g_pICWApp->m_haccel || !TranslateAccelerator(g_pICWApp->m_hWndApp,
  2369. g_pICWApp->m_haccel,
  2370. &msg))
  2371. {
  2372. if (!PropSheet_IsDialogMessage(gpWizardState->cmnStateData.hWndWizardPages, &msg))
  2373. {
  2374. TranslateMessage(&msg);
  2375. DispatchMessage(&msg);
  2376. }
  2377. }
  2378. }
  2379. }
  2380. else
  2381. {
  2382. // see if the app has any accelerators
  2383. if (!g_pICWApp->m_haccel || !TranslateAccelerator(g_pICWApp->m_hWndApp,
  2384. g_pICWApp->m_haccel,
  2385. &msg))
  2386. {
  2387. TranslateMessage(&msg);
  2388. DispatchMessage(&msg);
  2389. }
  2390. }
  2391. }
  2392. // Return the exit code to the system.
  2393. return ((BOOL)msg.wParam);
  2394. }
  2395. //**********************************************************************
  2396. //
  2397. // bRegisterHelperOC
  2398. //
  2399. // Purpose:
  2400. //
  2401. // Register the ICWCONN1 helper COM
  2402. //
  2403. // Parameters:
  2404. //
  2405. // None
  2406. //
  2407. // Return Value:
  2408. //
  2409. // None
  2410. //
  2411. //********************************************************************
  2412. BOOL bRegisterHelperOC
  2413. (
  2414. HINSTANCE hInstance,
  2415. UINT idLibString,
  2416. BOOL bReg
  2417. )
  2418. {
  2419. BOOL bRet = FALSE;
  2420. HINSTANCE hMod;
  2421. char szLib[MAX_PATH];
  2422. // Self register the COM that ICWCONN1 needs
  2423. // Because we load the DLL server into our own (ie, REGISTER.EXE)
  2424. // process space, call to initialize the OLE COM Library. Use the
  2425. // OLE SUCCEEDED macro to detect success. If fail then exit app
  2426. // with error message.
  2427. LoadStringA(hInstance, idLibString, szLib, sizeof(szLib));
  2428. // Load the Server DLL into our process space.
  2429. hMod = LoadLibraryA(szLib);
  2430. if (NULL != hMod)
  2431. {
  2432. HRESULT (STDAPICALLTYPE *pfn)(void);
  2433. // Extract the proper RegisterServer or UnRegisterServer entry point
  2434. if (bReg)
  2435. (FARPROC&)pfn = GetProcAddress(hMod, "DllRegisterServer");
  2436. else
  2437. (FARPROC&)pfn = GetProcAddress(hMod, "DllUnregisterServer");
  2438. // Call the entry point if we have it.
  2439. if (NULL != pfn)
  2440. {
  2441. if (FAILED((*pfn)()))
  2442. {
  2443. if (IsNT5() )
  2444. {
  2445. if (*g_szShellNext)
  2446. {
  2447. // 1 Process Shell Next
  2448. // 2 Set Completed Bit
  2449. // 3 Remove ICW icon grom desktop
  2450. UndoDesktopChanges(hInstance);
  2451. SetICWComplete();
  2452. }
  2453. else
  2454. {
  2455. TCHAR szTemp[MAX_MESSAGE_LEN];
  2456. TCHAR szPrivDenied[MAX_MESSAGE_LEN] = TEXT("\0");
  2457. LoadString(hInstance, IDS_INSUFFICIENT_PRIV1, szPrivDenied, MAX_PATH);
  2458. LoadString(hInstance, IDS_INSUFFICIENT_PRIV2, szTemp, MAX_PATH);
  2459. lstrcat(szPrivDenied, szTemp);
  2460. LoadString(hInstance, IDS_APPNAME, szTemp, MAX_PATH);
  2461. MessageBox(NULL, szPrivDenied, szTemp, MB_OK | MB_ICONINFORMATION);
  2462. }
  2463. }
  2464. else
  2465. {
  2466. MsgBox(NULL,IDS_DLLREG_FAIL,MB_ICONEXCLAMATION,MB_OK);
  2467. }
  2468. bRet = FALSE;
  2469. }
  2470. else
  2471. {
  2472. bRet = TRUE;
  2473. }
  2474. }
  2475. else
  2476. {
  2477. MsgBox(NULL,IDS_NODLLREG_FAIL,MB_ICONEXCLAMATION,MB_OK);
  2478. bRet = FALSE;
  2479. }
  2480. // Free the library
  2481. FreeLibrary(hMod);
  2482. }
  2483. else
  2484. {
  2485. MsgBox(NULL,IDS_LOADLIB_FAIL,MB_ICONEXCLAMATION,MB_OK);
  2486. bRet = FALSE;
  2487. }
  2488. return (bRet);
  2489. }
  2490. //**********************************************************************
  2491. //
  2492. // WinMain
  2493. //
  2494. // Purpose:
  2495. //
  2496. // Program entry point
  2497. //
  2498. // Parameters:
  2499. //
  2500. // HANDLE hInstance - Instance handle for this instance
  2501. //
  2502. // HANDLE hPrevInstance - Instance handle for the last instance
  2503. //
  2504. // LPTSTR lpCmdLine - Pointer to the command line
  2505. //
  2506. // int nCmdShow - Window State
  2507. //
  2508. // Return Value:
  2509. //
  2510. // msg.wParam
  2511. //
  2512. // Function Calls:
  2513. // Function Location
  2514. //
  2515. // CConnWizApp::CConnWizApp APP.CPP
  2516. // CConnWizApp::fInitApplication APP.CPP
  2517. // CConnWizApp::fInitInstance APP.CPP
  2518. // CConnWizApp::HandleAccelerators APP.CPP
  2519. // CConnWizApp::~CConnWizApp APP.CPP
  2520. // GetMessage Windows API
  2521. // TranslateMessage Windows API
  2522. // DispatchMessage Windows API
  2523. //
  2524. // Comments:
  2525. //
  2526. //********************************************************************
  2527. int PASCAL WinMainT(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow)
  2528. {
  2529. int iRetVal = 1;
  2530. #ifdef UNICODE
  2531. // Initialize the C runtime locale to the system locale.
  2532. setlocale(LC_ALL, "");
  2533. #endif
  2534. g_hInstance = hInstance;
  2535. //Do this here to minimize the chance that a user will ever see this
  2536. DeleteStartUpCommand();
  2537. // needed for LRPC to work properly...
  2538. SetMessageQueue(96);
  2539. if (FAILED(CoInitialize(NULL)))
  2540. return(0);
  2541. //Is the user an admin?
  2542. g_bUserIsAdmin = DoesUserHaveAdminPrivleges(hInstance);
  2543. g_bUserIsIEAKRestricted = CheckForIEAKRestriction(hInstance);
  2544. // Allocate memory for the global wizard state
  2545. gpWizardState = new WIZARDSTATE;
  2546. if (!gpWizardState)
  2547. {
  2548. MsgBox(NULL,IDS_ERR_OUTOFMEMORY,MB_ICONEXCLAMATION,MB_OK);
  2549. return 0;
  2550. }
  2551. // zero out structure
  2552. ZeroMemory(gpWizardState,sizeof(WIZARDSTATE));
  2553. SetDefaultProductCode(g_szProductCode,sizeof(g_szProductCode));
  2554. ZeroMemory(g_szPromoCode,sizeof(g_szPromoCode));
  2555. #ifndef ICWDEBUG
  2556. g_pszCmdLine = (TCHAR*)malloc((lstrlen(lpCmdLine) + 1)*sizeof(TCHAR));
  2557. if(g_pszCmdLine == NULL)
  2558. {
  2559. iRetVal = 0;
  2560. goto WinMainExit;
  2561. }
  2562. lstrcpy(g_pszCmdLine, lpCmdLine);
  2563. if (IsOemVer())
  2564. g_OEMOOBE = TRUE;
  2565. if (!(g_bRetProcessCmdLine = ProcessCommandLine(hInstance, lpCmdLine)))
  2566. {
  2567. iRetVal = 0;
  2568. goto WinMainExit;
  2569. }
  2570. if (g_OEMOOBE)
  2571. {
  2572. TCHAR szISPAppCmdLine[MAX_PATH];
  2573. TCHAR szOobeSwitch[MAX_PATH];
  2574. if (CheckOobeInfo(szOobeSwitch, szISPAppCmdLine))
  2575. {
  2576. if (IsWhistler())
  2577. {
  2578. // Ask if user want to run NCW or OEM version of OOBE
  2579. // [Windows Bug 325762]
  2580. INT_PTR nResult = DialogBox(hInstance,
  2581. MAKEINTRESOURCE(IDD_CHOOSEWIZARD),
  2582. NULL,
  2583. ChooseWizardDlgProc);
  2584. if (nResult == RUNWIZARD_OOBE)
  2585. {
  2586. // launch Mars sign-up on OEM preinstall machines which are
  2587. // configured with default offer as Mars [Windows Bug 347909]
  2588. if (szISPAppCmdLine[0] == TEXT('\0'))
  2589. {
  2590. StartOOBE(g_pszCmdLine, szOobeSwitch);
  2591. }
  2592. else
  2593. {
  2594. StartISPApp(szISPAppCmdLine, g_pszCmdLine);
  2595. }
  2596. }
  2597. else if (nResult == RUNWIZARD_NCW)
  2598. {
  2599. StartNCW(g_szShellNext, g_szShellNextParams);
  2600. }
  2601. }
  2602. else
  2603. {
  2604. StartOOBE(g_pszCmdLine, szOobeSwitch);
  2605. }
  2606. g_szShellNext[0] = TEXT('\0');
  2607. goto WinMainExit;
  2608. }
  2609. }
  2610. #endif
  2611. //Is the user an admin?
  2612. if(!g_bUserIsAdmin)
  2613. {
  2614. TCHAR szAdminDenied [MAX_PATH] = TEXT("\0");
  2615. TCHAR szAdminDeniedTitle [MAX_PATH] = TEXT("\0");
  2616. LoadString(hInstance, IDS_ADMIN_ACCESS_DENIED, szAdminDenied, MAX_PATH);
  2617. LoadString(hInstance, IDS_ADMIN_ACCESS_DENIED_TITLE, szAdminDeniedTitle, MAX_PATH);
  2618. MessageBox(NULL, szAdminDenied, szAdminDeniedTitle, MB_OK | MB_ICONSTOP);
  2619. TCHAR szOut[MAX_PATH];
  2620. // Get the first token
  2621. GetCmdLineToken(&lpCmdLine,szOut);
  2622. while (szOut[0])
  2623. {
  2624. GetShellNextToken(szOut, lpCmdLine);
  2625. // Eat the next token, it will be null if we are at the end
  2626. GetCmdLineToken(&lpCmdLine,szOut);
  2627. }
  2628. SetICWComplete();
  2629. goto WinMainExit;
  2630. }
  2631. //Has an admin restricted access through the IEAK?
  2632. if (g_bUserIsIEAKRestricted)
  2633. {
  2634. TCHAR szIEAKDenied[MAX_PATH];
  2635. TCHAR szIEAKDeniedTitle[MAX_PATH];
  2636. LoadString(hInstance, IDS_IEAK_ACCESS_DENIED, szIEAKDenied, MAX_PATH);
  2637. LoadString(hInstance, IDS_IEAK_ACCESS_DENIED_TITLE, szIEAKDeniedTitle, MAX_PATH);
  2638. MessageBox(NULL, szIEAKDenied, szIEAKDeniedTitle, MB_OK | MB_ICONSTOP);
  2639. //Yup, bail.
  2640. goto WinMainExit;
  2641. }
  2642. //Are we recovering from an OEM INS failure?
  2643. if (CheckForOemConfigFailure(hInstance))
  2644. {
  2645. QuickCompleteSignup();
  2646. //Yup, bail.
  2647. goto WinMainExit;
  2648. }
  2649. // Register ICWHELP.DLL
  2650. if (!bRegisterHelperOC(hInstance, IDS_HELPERLIB, TRUE))
  2651. {
  2652. iRetVal = 0;
  2653. goto WinMainExit;
  2654. }
  2655. // Register ICWUTIL.DLL
  2656. if (!bRegisterHelperOC(hInstance, IDS_UTILLIB, TRUE))
  2657. {
  2658. iRetVal = 0;
  2659. goto WinMainExit;
  2660. }
  2661. // Register ICWCONN.DLL
  2662. if (!bRegisterHelperOC(hInstance, IDS_WIZARDLIB, TRUE))
  2663. {
  2664. iRetVal = 0;
  2665. goto WinMainExit;
  2666. }
  2667. // initialize the app state structure
  2668. //-- do this here so we don't changed made in cmdln process
  2669. if (!InitWizardState(gpWizardState))
  2670. return 0;
  2671. if(!LoadString(g_hInstance, IDS_APPNAME, gpWizardState->cmnStateData.szWizTitle, ARRAYSIZE(gpWizardState->cmnStateData.szWizTitle)))
  2672. lstrcpy(gpWizardState->cmnStateData.szWizTitle, TEXT("Internet Connection Wizard"));
  2673. //we are being run from an OEM
  2674. if(g_bRunOnce)
  2675. {
  2676. //Do they have a connection
  2677. if(MyIsSmartStartEx(NULL, 0))
  2678. {
  2679. //Nope, look for oemconfig.ins
  2680. if(RunOemconfigIns())
  2681. goto WinMainExit;
  2682. }
  2683. else
  2684. {
  2685. //Yup, clean up desktop, set completed bit etc., then bail
  2686. QuickCompleteSignup();
  2687. goto WinMainExit;
  2688. }
  2689. }
  2690. // If there was not a shellnext passed on the CMD line, there might be
  2691. // one in the registry
  2692. if( g_szShellNext[0] == TEXT('\0'))
  2693. {
  2694. GetShellNextFromReg(g_szShellNext,g_szShellNextParams);
  2695. }
  2696. // We need to remove this entry now, so ICWMAN (INETWIZ) does not
  2697. // pick it up later
  2698. RemoveShellNextFromReg();
  2699. if (IsWhistler() &&
  2700. ((gpWizardState->cmnStateData.dwFlags & ICW_CFGFLAGS_NONCW) == 0))
  2701. {
  2702. // If we have shellnext, we want to run NCW instead [Windows Bug 325157]
  2703. if ( g_szShellNext[0] != TEXT('\0'))
  2704. {
  2705. StartNCW(g_szShellNext, g_szShellNextParams);
  2706. g_szShellNext[0] = TEXT('\0');
  2707. goto WinMainExit;
  2708. }
  2709. }
  2710. // Create an instance of the App Class
  2711. g_pICWApp = new CICWApp();
  2712. if (NULL == g_pICWApp)
  2713. {
  2714. iRetVal = 0;
  2715. goto WinMainExit;
  2716. }
  2717. // Superclass some dialog control types so we can correctly draw them
  2718. // transparently if we are using OEM customizations
  2719. SuperClassICWControls();
  2720. if (bCheckOEMCustomization())
  2721. iRetVal = RunSignupApp();
  2722. else
  2723. iRetVal = (RunSignupWizard(NULL) != NULL);
  2724. // Prepare for reboot if necessary
  2725. if (gfBackedUp == FALSE)
  2726. {
  2727. if (gpWizardState->fNeedReboot)
  2728. SetupForReboot(0);
  2729. }
  2730. // Cleanup the wizard state
  2731. ICWCleanup();
  2732. WinMainExit:
  2733. if (g_bUserIsAdmin && g_bRetProcessCmdLine && !g_bUserIsIEAKRestricted)
  2734. {
  2735. // Lets unregister the helper DLL
  2736. if (!bRegisterHelperOC(hInstance, IDS_HELPERLIB, FALSE))
  2737. {
  2738. iRetVal = 0;
  2739. }
  2740. if (!bRegisterHelperOC(hInstance, IDS_UTILLIB, FALSE))
  2741. {
  2742. iRetVal = 0;
  2743. }
  2744. if (!bRegisterHelperOC(hInstance, IDS_WIZARDLIB, FALSE))
  2745. {
  2746. iRetVal = 0;
  2747. }
  2748. // Nuke the ICWApp class
  2749. if (g_pICWApp)
  2750. {
  2751. delete g_pICWApp;
  2752. }
  2753. // Remove the superclassing for the ICW Controls
  2754. RemoveICWControlsSuperClass();
  2755. }
  2756. // deref from COM
  2757. CoUninitialize();
  2758. // free global structures
  2759. if (gpWizardState)
  2760. delete gpWizardState;
  2761. if(g_pszCmdLine)
  2762. free(g_pszCmdLine);
  2763. return (iRetVal); /* Returns the value from PostQuitMessage */
  2764. }
  2765. void RemoveDownloadDirectory (void)
  2766. {
  2767. DWORD dwAttribs;
  2768. TCHAR szDownloadDir[MAX_PATH];
  2769. TCHAR szSignedPID[MAX_PATH];
  2770. // form the ICW98 dir. It is basically the CWD
  2771. if (0 == GetCurrentDirectory(MAX_PATH, szDownloadDir))
  2772. return;
  2773. // remove the signed.pid file from the ICW directory (see BUG 373)
  2774. wsprintf(szSignedPID, TEXT("%s%s"), szDownloadDir, TEXT("\\signed.pid"));
  2775. if (GetFileAttributes(szSignedPID) != 0xFFFFFFFF)
  2776. {
  2777. SetFileAttributes(szSignedPID, FILE_ATTRIBUTE_NORMAL);
  2778. DeleteFile(szSignedPID);
  2779. }
  2780. lstrcat(szDownloadDir, TEXT("\\download"));
  2781. // See if the directory exists
  2782. dwAttribs = GetFileAttributes(szDownloadDir);
  2783. if (dwAttribs != 0xFFFFFFFF && dwAttribs & FILE_ATTRIBUTE_DIRECTORY)
  2784. DeleteDirectory(szDownloadDir);
  2785. }
  2786. #ifdef ICWDEBUG
  2787. void RemoveTempOfferDirectory (void)
  2788. {
  2789. DWORD dwAttribs;
  2790. TCHAR szDownloadDir[MAX_PATH];
  2791. // Set the current directory.
  2792. HKEY hkey = NULL;
  2793. TCHAR szAppPathKey[MAX_PATH];
  2794. TCHAR szICWPath[MAX_PATH];
  2795. DWORD dwcbPath = sizeof(szICWPath);
  2796. lstrcpy (szAppPathKey, REGSTR_PATH_APPPATHS);
  2797. lstrcat (szAppPathKey, TEXT("\\"));
  2798. lstrcat (szAppPathKey, TEXT("ICWCONN1.EXE"));
  2799. if ((RegOpenKeyEx(HKEY_LOCAL_MACHINE,szAppPathKey, 0, KEY_QUERY_VALUE, &hkey)) == ERROR_SUCCESS)
  2800. {
  2801. if (RegQueryValueEx(hkey, TEXT("Path"), NULL, NULL, (BYTE *)szICWPath, (DWORD *)&dwcbPath) == ERROR_SUCCESS)
  2802. {
  2803. // The Apppaths' have a trailing semicolon that we need to get rid of
  2804. // dwcbPath is the lenght of the string including the NULL terminator
  2805. int nSize = lstrlen(szICWPath);
  2806. if (nSize > 0)
  2807. szICWPath[nSize-1] = TEXT('\0');
  2808. //SetCurrentDirectory(szICWPath);
  2809. }
  2810. }
  2811. if (hkey)
  2812. RegCloseKey(hkey);
  2813. lstrcpy(szDownloadDir, szICWPath);
  2814. lstrcat(szDownloadDir, TEXT("\\tempoffer"));
  2815. // See if the directory exists
  2816. dwAttribs = GetFileAttributes(szDownloadDir);
  2817. if (dwAttribs != 0xFFFFFFFF && dwAttribs & FILE_ATTRIBUTE_DIRECTORY)
  2818. DeleteDirectory(szDownloadDir);
  2819. }
  2820. #endif
  2821. void DeleteDirectory (LPCTSTR szDirName)
  2822. {
  2823. WIN32_FIND_DATA fdata;
  2824. TCHAR szPath[MAX_PATH];
  2825. HANDLE hFile;
  2826. BOOL fDone;
  2827. wsprintf(szPath, TEXT("%s\\*.*"), szDirName);
  2828. hFile = FindFirstFile (szPath, &fdata);
  2829. if (INVALID_HANDLE_VALUE != hFile)
  2830. fDone = FALSE;
  2831. else
  2832. fDone = TRUE;
  2833. while (!fDone)
  2834. {
  2835. wsprintf(szPath, TEXT("%s\\%s"), szDirName, fdata.cFileName);
  2836. if (fdata.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
  2837. {
  2838. if (lstrcmpi(fdata.cFileName, TEXT(".")) != 0 &&
  2839. lstrcmpi(fdata.cFileName, TEXT("..")) != 0)
  2840. {
  2841. // recursively delete this dir too
  2842. DeleteDirectory(szPath);
  2843. }
  2844. }
  2845. else
  2846. {
  2847. SetFileAttributes(szPath, FILE_ATTRIBUTE_NORMAL);
  2848. DeleteFile(szPath);
  2849. }
  2850. if (FindNextFile(hFile, &fdata) == 0)
  2851. {
  2852. FindClose(hFile);
  2853. fDone = TRUE;
  2854. }
  2855. }
  2856. SetFileAttributes(szDirName, FILE_ATTRIBUTE_NORMAL);
  2857. RemoveDirectory(szDirName);
  2858. }
  2859. //+----------------------------------------------------------------------------
  2860. //
  2861. // Function AllocDialogIDList
  2862. //
  2863. // Synopsis Allocates memory for the g_pdwDialogIDList variable large enough
  2864. // to maintain 1 bit for every valid external dialog ID
  2865. //
  2866. // Arguments None
  2867. //
  2868. // Returns TRUE if allocation succeeds
  2869. // FALSE otherwise
  2870. //
  2871. // History 4/23/97 jmazner created
  2872. //
  2873. //-----------------------------------------------------------------------------
  2874. BOOL AllocDialogIDList( void )
  2875. {
  2876. ASSERT( NULL == g_pdwDialogIDList );
  2877. if( g_pdwDialogIDList )
  2878. {
  2879. TraceMsg(TF_ICWCONN1,TEXT("ICWCONN1: AllocDialogIDList called with non-null g_pdwDialogIDList!"));
  2880. return FALSE;
  2881. }
  2882. // determine maximum number of external dialogs we need to track
  2883. UINT uNumExternDlgs = EXTERNAL_DIALOGID_MAXIMUM - EXTERNAL_DIALOGID_MINIMUM + 1;
  2884. // we're going to need one bit for each dialogID.
  2885. // Find out how many DWORDS it'll take to get this many bits.
  2886. UINT uNumDWORDsNeeded = (uNumExternDlgs / ( 8 * sizeof(DWORD) )) + 1;
  2887. // set global var with length of the array
  2888. g_dwDialogIDListSize = uNumDWORDsNeeded;
  2889. g_pdwDialogIDList = (DWORD *) GlobalAlloc(GPTR, uNumDWORDsNeeded * sizeof(DWORD));
  2890. if( !g_pdwDialogIDList )
  2891. {
  2892. TraceMsg(TF_ICWCONN1,TEXT("ICWCONN1: AllocDialogIDList unable to allocate space for g_pdwDialogIDList!"));
  2893. return FALSE;
  2894. }
  2895. return TRUE;
  2896. }
  2897. //+----------------------------------------------------------------------------
  2898. //
  2899. // Function DialogIDAlreadyInUse
  2900. //
  2901. // Synopsis Checks whether a given dialog ID is marked as in use in the
  2902. // global array pointed to by g_pdwDialogIDList
  2903. //
  2904. // Arguments uDlgID -- Dialog ID to check
  2905. //
  2906. // Returns TRUE if -- DialogID is out of range defined by EXTERNAL_DIALOGID_*
  2907. // -- DialogID is marked as in use
  2908. // FALSE if DialogID is not marked as in use
  2909. //
  2910. // History 4/23/97 jmazner created
  2911. //
  2912. //-----------------------------------------------------------------------------
  2913. BOOL DialogIDAlreadyInUse( UINT uDlgID )
  2914. {
  2915. if( (uDlgID < EXTERNAL_DIALOGID_MINIMUM) ||
  2916. (uDlgID > EXTERNAL_DIALOGID_MAXIMUM) )
  2917. {
  2918. // this is an out-of-range ID, don't want to accept it.
  2919. TraceMsg(TF_ICWCONN1,TEXT("ICWCONN1: DialogIDAlreadyInUse received an out of range DialogID, %d"), uDlgID);
  2920. return TRUE;
  2921. }
  2922. // find which bit we need
  2923. UINT uBitToCheck = uDlgID - EXTERNAL_DIALOGID_MINIMUM;
  2924. UINT bitsInADword = 8 * sizeof(DWORD);
  2925. UINT baseIndex = uBitToCheck / bitsInADword;
  2926. ASSERT( (baseIndex < g_dwDialogIDListSize));
  2927. DWORD dwBitMask = 0x1 << uBitToCheck%bitsInADword;
  2928. BOOL fBitSet = g_pdwDialogIDList[baseIndex] & (dwBitMask);
  2929. return( fBitSet );
  2930. }
  2931. //+----------------------------------------------------------------------------
  2932. //
  2933. // Function SetDialogIDInUse
  2934. //
  2935. // Synopsis Sets or clears the in use bit for a given DialogID
  2936. //
  2937. // Arguments uDlgID -- Dialog ID for which to change status
  2938. // fInUse -- New value for the in use bit.
  2939. //
  2940. // Returns TRUE if status change succeeded.
  2941. // FALSE if DialogID is out of range defined by EXTERNAL_DIALOGID_*
  2942. //
  2943. // History 4/23/97 jmazner created
  2944. //
  2945. //-----------------------------------------------------------------------------
  2946. BOOL SetDialogIDInUse( UINT uDlgID, BOOL fInUse )
  2947. {
  2948. if( (uDlgID < EXTERNAL_DIALOGID_MINIMUM) ||
  2949. (uDlgID > EXTERNAL_DIALOGID_MAXIMUM) )
  2950. {
  2951. // this is an out-of-range ID, don't want to accept it.
  2952. TraceMsg(TF_ICWCONN1,TEXT("ICWCONN1: SetDialogIDInUse received an out of range DialogID, %d"), uDlgID);
  2953. return FALSE;
  2954. }
  2955. // find which bit we need
  2956. UINT uBitToCheck = uDlgID - EXTERNAL_DIALOGID_MINIMUM;
  2957. UINT bitsInADword = 8 * sizeof(DWORD);
  2958. UINT baseIndex = uBitToCheck / bitsInADword;
  2959. ASSERT( (baseIndex < g_dwDialogIDListSize));
  2960. DWORD dwBitMask = 0x1 << uBitToCheck%bitsInADword;
  2961. if( fInUse )
  2962. {
  2963. g_pdwDialogIDList[baseIndex] |= (dwBitMask);
  2964. }
  2965. else
  2966. {
  2967. g_pdwDialogIDList[baseIndex] &= ~(dwBitMask);
  2968. }
  2969. return TRUE;
  2970. }
  2971. BOOL CheckForIEAKRestriction(HINSTANCE hInstance)
  2972. {
  2973. HKEY hkey = NULL;
  2974. BOOL bRC = FALSE;
  2975. DWORD dwType = 0;
  2976. DWORD dwSize = 0;
  2977. DWORD dwData = 0;
  2978. if (ERROR_SUCCESS == RegOpenKey(HKEY_CURRENT_USER,
  2979. IEAK_RESTRICTION_REGKEY,&hkey))
  2980. {
  2981. dwSize = sizeof(dwData);
  2982. if (ERROR_SUCCESS == RegQueryValueEx(hkey,IEAK_RESTRICTION_REGKEY_VALUE,0,&dwType,
  2983. (LPBYTE)&dwData,&dwSize))
  2984. {
  2985. if (dwData)
  2986. {
  2987. bRC = TRUE;
  2988. }
  2989. }
  2990. }
  2991. if (hkey)
  2992. RegCloseKey(hkey);
  2993. return bRC;
  2994. }
  2995. //+----------------------------------------------------------------------------
  2996. //
  2997. // Function StartISPApp
  2998. //
  2999. // Synopsis Launch ISP App as a detached process and pass the ICW command line
  3000. // to the ISP App.
  3001. //
  3002. // Arguments pszISPPath - ISP Application command line, including the
  3003. // application name and additional arguments
  3004. //
  3005. // pszCmdLine - ICW command line arguments (without ICW executable
  3006. // name). It must not be NULL, but can be empty.
  3007. //
  3008. //
  3009. // Returns none
  3010. //
  3011. // History 3/11/01 chunhoc created
  3012. //
  3013. //-----------------------------------------------------------------------------
  3014. VOID
  3015. StartISPApp(
  3016. IN LPTSTR pszISPPath,
  3017. IN LPTSTR pszCmdLine)
  3018. {
  3019. static const TCHAR COMMANDLINE_FORMAT[] = TEXT("%s %s");
  3020. LPTSTR szCommandLine = NULL;
  3021. int cchCommandLine;
  3022. int i;
  3023. cchCommandLine = sizeof(COMMANDLINE_FORMAT) / sizeof(TCHAR) +
  3024. lstrlen(pszISPPath) + lstrlen(pszCmdLine) + 1;
  3025. szCommandLine = (LPTSTR) LocalAlloc(LPTR, cchCommandLine * sizeof(TCHAR));
  3026. if (szCommandLine == NULL)
  3027. {
  3028. goto cleanup;
  3029. }
  3030. i = wsprintf(szCommandLine, COMMANDLINE_FORMAT, pszISPPath, pszCmdLine);
  3031. ASSERT(i <= cchCommandLine);
  3032. MyExecute(szCommandLine);
  3033. cleanup:
  3034. if (szCommandLine != NULL)
  3035. {
  3036. LocalFree(szCommandLine);
  3037. }
  3038. }
  3039. //+----------------------------------------------------------------------------
  3040. //
  3041. // Function StartOOBE
  3042. //
  3043. // Synopsis Launch OOBE as a detached process and pass the ICW command line
  3044. // and additional switch to OOBE.
  3045. //
  3046. // Arguments pszCmdLine - ICW command line arguments (without ICW executable
  3047. // name). It must not be NULL, but can be empty.
  3048. //
  3049. // pszOobeSwitch - additional OOBE specific switch. It must not be
  3050. // NULL, but can be empty.
  3051. //
  3052. // Returns none
  3053. //
  3054. // History 3/11/01 chunhoc created
  3055. //
  3056. //-----------------------------------------------------------------------------
  3057. VOID
  3058. StartOOBE(
  3059. IN LPTSTR pszCmdLine,
  3060. IN LPTSTR pszOobeSwitch)
  3061. {
  3062. static const TCHAR COMMANDLINE_FORMAT[] = TEXT("%s\\msoobe.exe %s %s");
  3063. TCHAR szOOBEPath[MAX_PATH];
  3064. LPTSTR szCommandLine = NULL;
  3065. int cchCommandLine;
  3066. int i;
  3067. if (GetSystemDirectory(szOOBEPath, MAX_PATH) == 0)
  3068. {
  3069. goto cleanup;
  3070. }
  3071. lstrcat(szOOBEPath, TEXT("\\oobe"));
  3072. cchCommandLine = sizeof(COMMANDLINE_FORMAT) / sizeof(TCHAR) +
  3073. lstrlen(szOOBEPath) + lstrlen(pszCmdLine) + lstrlen(pszOobeSwitch) + 1;
  3074. szCommandLine = (LPTSTR) LocalAlloc(LPTR, cchCommandLine * sizeof(TCHAR));
  3075. if (szCommandLine == NULL)
  3076. {
  3077. goto cleanup;
  3078. }
  3079. i = wsprintf(szCommandLine, COMMANDLINE_FORMAT, szOOBEPath, pszCmdLine, pszOobeSwitch);
  3080. ASSERT(i <= cchCommandLine);
  3081. SetCurrentDirectory(szOOBEPath);
  3082. MyExecute(szCommandLine);
  3083. cleanup:
  3084. if (szCommandLine != NULL)
  3085. {
  3086. LocalFree(szCommandLine);
  3087. }
  3088. }
  3089. //+----------------------------------------------------------------------------
  3090. //
  3091. // Function StartNCW
  3092. //
  3093. // Synopsis Launch NCW as a detached process and pass the shellnext to it.
  3094. // NCW is supposed to handle shellnext and
  3095. // disable ICW smart start on successful configuration
  3096. //
  3097. // Arguments szShellNext - shellnext
  3098. //
  3099. // szShellNextParams - argument to shellnext
  3100. //
  3101. // Returns none
  3102. //
  3103. // History 3/11/01 chunhoc created
  3104. //
  3105. //-----------------------------------------------------------------------------
  3106. VOID
  3107. StartNCW(
  3108. IN LPTSTR szShellNext,
  3109. IN LPTSTR szShellNextParams)
  3110. {
  3111. static const TCHAR COMMANDLINE_FORMAT[] =
  3112. TEXT("%s\\rundll32.exe %s\\netshell.dll StartNCW %d,%s,%s");
  3113. static const int NCW_FIRST_PAGE = 0;
  3114. static const int NCW_MAX_PAGE_NO_LENGTH = 5;
  3115. TCHAR szSystemDir[MAX_PATH];
  3116. int cchSystemDir;
  3117. LPTSTR szCommandLine = NULL;
  3118. int cchCommandLine;
  3119. int i;
  3120. if ((cchSystemDir = GetSystemDirectory(szSystemDir, MAX_PATH)) == 0)
  3121. {
  3122. goto cleanup;
  3123. }
  3124. cchCommandLine = sizeof(COMMANDLINE_FORMAT) / sizeof(TCHAR) + cchSystemDir * 2 +
  3125. lstrlen(szShellNext) + lstrlen(szShellNextParams) + NCW_MAX_PAGE_NO_LENGTH + 1;
  3126. szCommandLine = (LPTSTR) LocalAlloc(LPTR, cchCommandLine * sizeof(TCHAR));
  3127. if (szCommandLine == NULL)
  3128. {
  3129. goto cleanup;
  3130. }
  3131. i = wsprintf(szCommandLine, COMMANDLINE_FORMAT, szSystemDir, szSystemDir,
  3132. NCW_FIRST_PAGE, szShellNext, szShellNextParams);
  3133. ASSERT(i <= cchCommandLine);
  3134. MyExecute(szCommandLine);
  3135. cleanup:
  3136. if (szCommandLine != NULL)
  3137. {
  3138. LocalFree(szCommandLine);
  3139. }
  3140. }
  3141. //+----------------------------------------------------------------------------
  3142. //
  3143. // Function ChooseWizardDlgProc
  3144. //
  3145. // Synopsis Let user to determine if they want to run NCW or OEM
  3146. // customized OOBE
  3147. //
  3148. // Arguments (standard DialogProc, see MSDN)
  3149. //
  3150. // Returns RUNWIZARD_CANCEL - if user doesn't want to run any wizard
  3151. // RUNWIZARD_OOBE - if user wants to run OEM customized OOBE
  3152. // RUNWIZARD_NCW - if user wants to run NCW
  3153. //
  3154. // History 3/11/01 chunhoc created
  3155. //
  3156. //-----------------------------------------------------------------------------
  3157. INT_PTR CALLBACK
  3158. ChooseWizardDlgProc(
  3159. IN HWND hwnd,
  3160. IN UINT uMsg,
  3161. IN WPARAM wParam,
  3162. IN LPARAM lParam)
  3163. {
  3164. switch (uMsg)
  3165. {
  3166. case WM_INITDIALOG:
  3167. {
  3168. RECT rcDialog;
  3169. CheckRadioButton(hwnd, IDC_RUN_OOBE, IDC_RUN_NCW, IDC_RUN_OOBE);
  3170. if (GetWindowRect(hwnd, &rcDialog))
  3171. {
  3172. int cxWidth = rcDialog.right - rcDialog.left;
  3173. int cyHeight = rcDialog.bottom - rcDialog.top;
  3174. int cxDialog = (GetSystemMetrics(SM_CXSCREEN) - cxWidth) / 2;
  3175. int cyDialog = (GetSystemMetrics(SM_CYSCREEN) - cyHeight) / 2;
  3176. MoveWindow(hwnd, cxDialog, cyDialog, cxWidth, cyHeight, FALSE);
  3177. }
  3178. MakeBold(GetDlgItem(hwnd, IDC_CHOOSEWIZARD_TITLE), TRUE, FW_BOLD);
  3179. return TRUE;
  3180. }
  3181. case WM_CTLCOLORSTATIC:
  3182. {
  3183. if (GetDlgCtrlID((HWND)lParam) == IDC_CHOOSEWIZARD_TITLE)
  3184. {
  3185. HBRUSH hbr = (HBRUSH) GetStockObject(WHITE_BRUSH);
  3186. SetBkMode((HDC)wParam, TRANSPARENT);
  3187. return (LRESULT)hbr;
  3188. }
  3189. }
  3190. case WM_COMMAND:
  3191. {
  3192. WORD id = LOWORD(wParam);
  3193. switch (id)
  3194. {
  3195. case IDOK:
  3196. if (IsDlgButtonChecked(hwnd, IDC_RUN_OOBE))
  3197. {
  3198. EndDialog(hwnd, RUNWIZARD_OOBE);
  3199. }
  3200. else
  3201. {
  3202. EndDialog(hwnd, RUNWIZARD_NCW);
  3203. }
  3204. break;
  3205. case IDCANCEL:
  3206. EndDialog(hwnd, RUNWIZARD_CANCEL);
  3207. break;
  3208. }
  3209. return TRUE;
  3210. }
  3211. case WM_DESTROY:
  3212. {
  3213. ReleaseBold(GetDlgItem(hwnd, IDC_CHOOSEWIZARD_TITLE));
  3214. return 0;
  3215. }
  3216. }
  3217. return(FALSE);
  3218. }
  3219. //+----------------------------------------------------------------------------
  3220. //
  3221. // Function MyExecute
  3222. //
  3223. // Synopsis Run a command line in a detached process
  3224. //
  3225. // Arguments szCommandLine - the command line to be executed
  3226. //
  3227. // Returns TRUE if the process is created; FALSE otherwise
  3228. //
  3229. // History 3/27/01 chunhoc created
  3230. //
  3231. //-----------------------------------------------------------------------------
  3232. BOOL
  3233. MyExecute(
  3234. IN LPTSTR szCommandLine)
  3235. {
  3236. PROCESS_INFORMATION pi;
  3237. STARTUPINFO si;
  3238. BOOL bRet;
  3239. ZeroMemory(&si, sizeof(si));
  3240. si.cb = sizeof(si);
  3241. ZeroMemory(&pi, sizeof(pi));
  3242. if (CreateProcess(NULL,
  3243. szCommandLine,
  3244. NULL,
  3245. NULL,
  3246. FALSE,
  3247. 0,
  3248. NULL,
  3249. NULL,
  3250. &si,
  3251. &pi) == TRUE)
  3252. {
  3253. CloseHandle(pi.hThread);
  3254. CloseHandle(pi.hProcess);
  3255. bRet = TRUE;
  3256. }
  3257. else
  3258. {
  3259. bRet = FALSE;
  3260. }
  3261. return bRet;
  3262. }
  3263. LONG
  3264. MakeBold (
  3265. IN HWND hwnd,
  3266. IN BOOL fSize,
  3267. IN LONG lfWeight)
  3268. {
  3269. LONG hr = ERROR_SUCCESS;
  3270. HFONT hfont = NULL;
  3271. HFONT hnewfont = NULL;
  3272. LOGFONT* plogfont = NULL;
  3273. if (!hwnd) goto MakeBoldExit;
  3274. hfont = (HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
  3275. if (!hfont)
  3276. {
  3277. hr = ERROR_GEN_FAILURE;
  3278. goto MakeBoldExit;
  3279. }
  3280. plogfont = (LOGFONT*)malloc(sizeof(LOGFONT));
  3281. if (!plogfont)
  3282. {
  3283. hr = ERROR_NOT_ENOUGH_MEMORY;
  3284. goto MakeBoldExit;
  3285. }
  3286. if (!GetObject(hfont,sizeof(LOGFONT),(LPVOID)plogfont))
  3287. {
  3288. hr = ERROR_GEN_FAILURE;
  3289. goto MakeBoldExit;
  3290. }
  3291. plogfont->lfWeight = (int) lfWeight;
  3292. if (!(hnewfont = CreateFontIndirect(plogfont)))
  3293. {
  3294. hr = ERROR_GEN_FAILURE;
  3295. goto MakeBoldExit;
  3296. }
  3297. SendMessage(hwnd,WM_SETFONT,(WPARAM)hnewfont,MAKELPARAM(TRUE,0));
  3298. MakeBoldExit:
  3299. if (plogfont)
  3300. {
  3301. free(plogfont);
  3302. }
  3303. return hr;
  3304. }
  3305. LONG
  3306. ReleaseBold(
  3307. HWND hwnd)
  3308. {
  3309. HFONT hfont = NULL;
  3310. hfont = (HFONT)SendMessage(hwnd,WM_GETFONT,0,0);
  3311. if (hfont) DeleteObject(hfont);
  3312. return ERROR_SUCCESS;
  3313. }