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.

902 lines
25 KiB

  1. //*******************************************************************
  2. //
  3. // Copyright (c) 1996-1998 Microsoft Corporation
  4. //
  5. // FILE: EXPORT.C
  6. //
  7. // PURPOSE: Contains external API's for use by signup wizard.
  8. //
  9. // HISTORY:
  10. // 96/03/05 markdu Created.
  11. // 96/03/11 markdu Added InetConfigClient()
  12. // 96/03/11 markdu Added InetGetAutodial() and InetSetAutodial().
  13. // 96/03/12 markdu Added UI during file install.
  14. // 96/03/12 markdu Added ValidateConnectoidData().
  15. // 96/03/12 markdu Set connectoid for autodial if INETCFG_SETASAUTODIAL
  16. // is set. Renamed ValidateConnectoidData to MakeConnectoid.
  17. // 96/03/12 markdu Added hwnd param to InetConfigClient() and
  18. // InetConfigSystem().
  19. // 96/03/13 markdu Added INETCFG_OVERWRITEENTRY. Create unique neame
  20. // for connectoid if it already exists and we can't overwrite.
  21. // 96/03/13 markdu Added InstallTCPAndRNA().
  22. // 96/03/13 markdu Added LPINETCLIENTINFO param to InetConfigClient()
  23. // 96/03/16 markdu Added INETCFG_INSTALLMODEM flag.
  24. // 96/03/16 markdu Use ReInit member function to re-enumerate modems.
  25. // 96/03/19 markdu Split export.h into export.h and csexport.h
  26. // 96/03/20 markdu Combined export.h and iclient.h into inetcfg.h
  27. // 96/03/23 markdu Replaced CLIENTINFO references with CLIENTCONFIG.
  28. // 96/03/24 markdu Replaced lstrcpy with lstrcpyn where appropriate.
  29. // 96/03/25 markdu Validate lpfNeedsRestart before using.
  30. // 96/03/25 markdu Clean up some error handling.
  31. // 96/03/26 markdu Use MAX_ISP_NAME instead of RAS_MaxEntryName
  32. // because of bug in RNA.
  33. // 96/03/26 markdu Implemented UpdateMailSettings().
  34. // 96/03/27 mmaclin InetGetProxy()and InetSetProxy().
  35. // 96/04/04 markdu NASH BUG 15610 Check for file and printer sharing
  36. // bound to TCP/IP .
  37. // 96/04/04 markdu Added phonebook name param to InetConfigClient,
  38. // MakeConnectoid, SetConnectoidUsername, CreateConnectoid,
  39. // and ValidateConnectoidName.
  40. // 96/04/05 markdu Set internet icon on desktop to point to browser.
  41. // 96/04/06 mmaclin Changed InetSetProxy to check for NULL.
  42. // 96/04/06 markdu NASH BUG 16404 Initialize gpWizardState in
  43. // UpdateMailSettings.
  44. // 96/04/06 markdu NASH BUG 16441 If InetSetAutodial is called with NULL
  45. // as the connection name, the entry is not changed.
  46. // 96/04/18 markdu NASH BUG 18443 Make exports WINAPI.
  47. // 96/04/19 markdu NASH BUG 18605 Handle ERROR_FILE_NOT_FOUND return
  48. // from ValidateConnectoidName.
  49. // 96/04/19 markdu NASH BUG 17760 Do not show choose profile UI.
  50. // 96/04/22 markdu NASH BUG 18901 Do not set desktop internet icon to
  51. // browser if we are just creating a temp connectoid.
  52. // 96/04/23 markdu NASH BUG 18719 Make the choose profile dialog TOPMOST.
  53. // 96/04/25 markdu NASH BUG 19572 Only show choose profile dialog if
  54. // there is an existing profile.
  55. // 96/04/29 markdu NASH BUG 20003 Added InetConfigSystemFromPath
  56. // and removed InstallTCPAndRNA.
  57. // 96/05/01 markdu NASH BUG 20483 Do not display "installing files" dialog
  58. // if INETCFG_SUPPRESSINSTALLUI is set.
  59. // 96/05/01 markdu ICW BUG 8049 Reboot if modem is installed. This is
  60. // required because sometimes the configuration manager does not
  61. // set up the modem correctly, and the user will not be able to
  62. // dial (will get cryptic error message) until reboot.
  63. // 96/05/06 markdu NASH BUG 21027 If DNS is set globally, clear it out so
  64. // the per-connectoid settings will be saved.
  65. // 96/05/14 markdu NASH BUG 21706 Removed BigFont functions.
  66. // 96/05/25 markdu Use ICFG_ flags for lpNeedDrivers and lpInstallDrivers.
  67. // 96/05/27 markdu Use lpIcfgInstallInetComponents and lpIcfgNeedInetComponents.
  68. // 96/05/28 markdu Moved InitConfig and DeInitConfig to DllEntryPoint.
  69. // 96/10/21 valdonb Added CheckConnectionWizard and InetCreateMailNewsAccount
  70. // 99/11/10 nickball Reduced to CM essentials
  71. //
  72. //*******************************************************************
  73. #include "wizard.h"
  74. #include "inetcfg.h"
  75. // structure to pass data back from IDD_NEEDDRIVERS handler
  76. typedef struct tagNEEDDRIVERSDLGINFO
  77. {
  78. DWORD dwfOptions;
  79. LPBOOL lpfNeedsRestart;
  80. } NEEDDRIVERSDLGINFO, * PNEEDDRIVERSDLGINFO;
  81. // Function prototypes internal to this file
  82. INT_PTR CALLBACK NeedDriversDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  83. LPARAM lParam);
  84. BOOL NeedDriversDlgInit(HWND hDlg,PNEEDDRIVERSDLGINFO pNeedDriversDlgInfo);
  85. BOOL NeedDriversDlgOK(HWND hDlg,PNEEDDRIVERSDLGINFO pNeedDriversDlgInfo);
  86. VOID EnableDlg(HWND hDlg,BOOL fEnable);
  87. static DWORD GetOSMajorVersion(void);
  88. // from rnacall.cpp
  89. //
  90. extern void InitTAPILocation(HWND hwndParent);
  91. // Function prototypes external to this file
  92. extern ICFGINSTALLSYSCOMPONENTS lpIcfgInstallInetComponents;
  93. extern ICFGNEEDSYSCOMPONENTS lpIcfgNeedInetComponents;
  94. extern ICFGGETLASTINSTALLERRORTEXT lpIcfgGetLastInstallErrorText;
  95. //*******************************************************************
  96. //
  97. // FUNCTION: InetConfigSystem
  98. //
  99. // PURPOSE: This function will install files that are needed
  100. // for internet access (such as TCP/IP and RNA) based
  101. // the state of the options flags.
  102. //
  103. // PARAMETERS: hwndParent - window handle of calling application. This
  104. // handle will be used as the parent for any dialogs that
  105. // are required for error messages or the "installing files"
  106. // dialog.
  107. // dwfOptions - a combination of INETCFG_ flags that controls
  108. // the installation and configuration as follows:
  109. //
  110. // INETCFG_INSTALLMAIL - install exchange and internet mail
  111. // INETCFG_INSTALLMODEM - Invoke InstallModem wizard if NO
  112. // MODEM IS INSTALLED.
  113. // INETCFG_INSTALLRNA - install RNA (if needed)
  114. // INETCFG_INSTALLTCP - install TCP/IP (if needed)
  115. // INETCFG_CONNECTOVERLAN - connecting with LAN (vs modem)
  116. // INETCFG_WARNIFSHARINGBOUND - Check if TCP/IP file sharing is
  117. // turned on, and warn user to turn
  118. // it off. Reboot is required if
  119. // the user turns it off.
  120. // INETCFG_REMOVEIFSHARINGBOUND - Check if TCP/IP file sharing is
  121. // turned on, and force user to turn
  122. // it off. If user does not want to
  123. // turn it off, return will be
  124. // ERROR_CANCELLED. Reboot is
  125. // required if the user turns it off.
  126. //
  127. // lpfNeedsRestart - if non-NULL, then on return, this will be
  128. // TRUE if windows must be restarted to complete the installation.
  129. //
  130. // RETURNS: HRESULT code, ERROR_SUCCESS if no errors occurred
  131. //
  132. // HISTORY:
  133. // 96/03/05 markdu Created.
  134. //
  135. //*******************************************************************
  136. extern "C" HRESULT WINAPI InetConfigSystem(
  137. HWND hwndParent,
  138. DWORD dwfOptions,
  139. LPBOOL lpfNeedsRestart)
  140. {
  141. DWORD dwRet = ERROR_SUCCESS;
  142. BOOL fNeedsRestart = FALSE; // Default to no reboot needed
  143. // 4/2/97 ChrisK Olympus 209
  144. HWND hwndWaitDlg = NULL;
  145. CHAR szWindowTitle[255];
  146. BOOL bSleepNeeded = FALSE;
  147. DEBUGMSG("export.c::InetConfigSystem()");
  148. // Validate the parent hwnd
  149. if (hwndParent && !IsWindow(hwndParent))
  150. {
  151. return ERROR_INVALID_PARAMETER;
  152. }
  153. // Set up the install options
  154. DWORD dwfInstallOptions = 0;
  155. if (dwfOptions & INETCFG_INSTALLTCP)
  156. {
  157. dwfInstallOptions |= ICFG_INSTALLTCP;
  158. }
  159. if (dwfOptions & INETCFG_INSTALLRNA)
  160. {
  161. dwfInstallOptions |= ICFG_INSTALLRAS;
  162. }
  163. if (dwfOptions & INETCFG_INSTALLMAIL)
  164. {
  165. dwfInstallOptions |= ICFG_INSTALLMAIL;
  166. }
  167. // see if we need to install drivers
  168. BOOL fNeedSysComponents = FALSE;
  169. //
  170. // Kill Modem control panel if it's already running
  171. // 4/16/97 ChrisK Olympus 239
  172. // 6/9/97 jmazner moved this functionality from InvokeModemWizard
  173. szWindowTitle[0] = '\0';
  174. LoadSz(IDS_MODEM_WIZ_TITLE,szWindowTitle,255);
  175. HWND hwndModem = FindWindow("#32770",szWindowTitle);
  176. if (NULL != hwndModem)
  177. {
  178. // Close modem installation wizard
  179. PostMessage(hwndModem, WM_CLOSE, 0, 0);
  180. bSleepNeeded = TRUE;
  181. }
  182. // close modem control panel applet
  183. LoadSz(IDS_MODEM_CPL_TITLE,szWindowTitle,255);
  184. hwndModem = FindWindow("#32770",szWindowTitle);
  185. if (NULL != hwndModem)
  186. {
  187. PostMessage(hwndModem, WM_SYSCOMMAND,SC_CLOSE, 0);
  188. bSleepNeeded = TRUE;
  189. }
  190. if (bSleepNeeded)
  191. {
  192. Sleep(1000);
  193. }
  194. dwRet = lpIcfgNeedInetComponents(dwfInstallOptions, &fNeedSysComponents);
  195. if (ERROR_SUCCESS != dwRet)
  196. {
  197. CHAR szErrorText[MAX_ERROR_TEXT+1]="";
  198. // 4/2/97 ChrisK Olympus 209
  199. // Dismiss busy dialog
  200. if (NULL != hwndWaitDlg)
  201. {
  202. DestroyWindow(hwndWaitDlg);
  203. hwndWaitDlg = NULL;
  204. }
  205. //
  206. // Get the text of the error message and display it.
  207. //
  208. if (lpIcfgGetLastInstallErrorText(szErrorText, MAX_ERROR_TEXT+1))
  209. {
  210. MsgBoxSz(NULL,szErrorText,MB_ICONEXCLAMATION,MB_OK);
  211. }
  212. return dwRet;
  213. }
  214. if (fNeedSysComponents)
  215. {
  216. // 4/2/97 ChrisK Olympus 209
  217. // if we are going to install something the busy dialog isn't needed
  218. if (NULL != hwndWaitDlg)
  219. ShowWindow(hwndWaitDlg,SW_HIDE);
  220. if (dwfOptions & INETCFG_SUPPRESSINSTALLUI)
  221. {
  222. dwRet = lpIcfgInstallInetComponents(hwndParent, dwfInstallOptions, &fNeedsRestart);
  223. //
  224. // Display error message only if it failed due to something
  225. // other than user cancel
  226. //
  227. if ((ERROR_SUCCESS != dwRet) && (ERROR_CANCELLED != dwRet))
  228. {
  229. CHAR szErrorText[MAX_ERROR_TEXT+1]="";
  230. // Get the text of the error message and display it.
  231. if (lpIcfgGetLastInstallErrorText(szErrorText, MAX_ERROR_TEXT+1))
  232. {
  233. MsgBoxSz(NULL,szErrorText,MB_ICONEXCLAMATION,MB_OK);
  234. }
  235. }
  236. }
  237. else
  238. {
  239. // structure to pass to dialog to fill out
  240. NEEDDRIVERSDLGINFO NeedDriversDlgInfo;
  241. NeedDriversDlgInfo.dwfOptions = dwfInstallOptions;
  242. NeedDriversDlgInfo.lpfNeedsRestart = &fNeedsRestart;
  243. // Clear out the last error code so we can safely use it.
  244. SetLastError(ERROR_SUCCESS);
  245. // Display a dialog and allow the user to cancel install
  246. BOOL fRet = (BOOL)DialogBoxParam(ghInstance,MAKEINTRESOURCE(IDD_NEEDDRIVERS),hwndParent,
  247. NeedDriversDlgProc,(LPARAM) &NeedDriversDlgInfo);
  248. if (FALSE == fRet)
  249. {
  250. // user cancelled or an error occurred.
  251. dwRet = GetLastError();
  252. if (ERROR_SUCCESS == dwRet)
  253. {
  254. // Error occurred, but the error code was not set.
  255. dwRet = ERROR_INETCFG_UNKNOWN;
  256. }
  257. }
  258. }
  259. }
  260. if ((ERROR_SUCCESS == dwRet) &&
  261. (TRUE == IsNT()) &&
  262. (dwfOptions & INETCFG_INSTALLMODEM))
  263. {
  264. BOOL bNeedModem = FALSE;
  265. if (NULL == lpIcfgNeedModem)
  266. {
  267. //
  268. // 4/2/97 ChrisK Olympus 209
  269. //
  270. if (NULL != hwndWaitDlg)
  271. DestroyWindow(hwndWaitDlg);
  272. hwndWaitDlg = NULL;
  273. return ERROR_GEN_FAILURE;
  274. }
  275. //
  276. // 4/2/97 ChrisK Olympus 209
  277. // Show busy dialog here, this can take a few seconds
  278. //
  279. if (NULL != hwndWaitDlg)
  280. ShowWindow(hwndWaitDlg,SW_SHOW);
  281. dwRet = (*lpIcfgNeedModem)(0, &bNeedModem);
  282. if (ERROR_SUCCESS != dwRet)
  283. {
  284. //
  285. // 4/2/97 ChrisK Olympus 209
  286. //
  287. if (NULL != hwndWaitDlg)
  288. DestroyWindow(hwndWaitDlg);
  289. hwndWaitDlg = NULL;
  290. return dwRet;
  291. }
  292. if (TRUE == bNeedModem)
  293. {
  294. if (GetOSMajorVersion() != 5)
  295. {
  296. //
  297. // Not NT4 we cannot programmitcally install/configure modem
  298. // separately. It has to be done when RAS in installed
  299. //
  300. if (NULL != hwndWaitDlg)
  301. DestroyWindow(hwndWaitDlg);
  302. hwndWaitDlg = NULL;
  303. MsgBoxParam(hwndParent,IDS_ERRNoDialOutModem,MB_ICONERROR,MB_OK);
  304. return ERROR_GEN_FAILURE;
  305. }
  306. else
  307. {
  308. //
  309. // Attempt to install Modem
  310. //
  311. BOOL bNeedToReboot = FALSE;
  312. if (NULL != hwndWaitDlg)
  313. DestroyWindow(hwndWaitDlg);
  314. hwndWaitDlg = NULL;
  315. dwRet = (*lpIcfgInstallModem)(NULL, 0, &bNeedToReboot);
  316. if (ERROR_SUCCESS == dwRet)
  317. {
  318. ASSERT(!bNeedToReboot);
  319. //
  320. // Need to check if user managed to add a modem
  321. //
  322. dwRet = (*lpIcfgNeedModem)(0, &bNeedModem);
  323. if (TRUE == bNeedModem)
  324. {
  325. //
  326. // User must have cancelled the modem setup
  327. //
  328. return ERROR_CANCELLED;
  329. }
  330. }
  331. else
  332. {
  333. return ERROR_GEN_FAILURE;
  334. }
  335. }
  336. }
  337. }
  338. //
  339. // 4/2/97 ChrisK Olympus 209
  340. //
  341. if (NULL != hwndWaitDlg)
  342. ShowWindow(hwndWaitDlg,SW_HIDE);
  343. // 4/2/97 ChrisK Olympus 209
  344. // Dismiss dialog for good
  345. if (NULL != hwndWaitDlg)
  346. DestroyWindow(hwndWaitDlg);
  347. hwndWaitDlg = NULL;
  348. //
  349. // If not NT then we install the modem after installing RAS
  350. //
  351. // See if we are supposed to install a modem
  352. if ((FALSE == IsNT()) && (ERROR_SUCCESS == dwRet) &&
  353. (dwfOptions & INETCFG_INSTALLMODEM))
  354. {
  355. // Load RNA if not already loaded since ENUM_MODEM needs it.
  356. dwRet = EnsureRNALoaded();
  357. if (ERROR_SUCCESS != dwRet)
  358. {
  359. return dwRet;
  360. }
  361. // Enumerate the modems
  362. ENUM_MODEM EnumModem;
  363. dwRet = EnumModem.GetError();
  364. if (ERROR_SUCCESS != dwRet)
  365. {
  366. return dwRet;
  367. }
  368. // If there are no modems, install one if requested.
  369. if (0 == EnumModem.GetNumDevices())
  370. {
  371. if (FALSE == IsNT())
  372. {
  373. //
  374. // 5/22/97 jmazner Olympus #4698
  375. // On Win95, calling RasEnumDevices launches RNAAP.EXE
  376. // If RNAAP.EXE is running, any modems you install won't be usable
  377. // So, nuke RNAAP.EXE before installing the modem.
  378. //
  379. CHAR szOtherWindowTitle[255] = "\0nogood";
  380. //
  381. // Unload the RAS dll's before killing RNAAP, just to be safe
  382. //
  383. DeInitRNA();
  384. LoadSz(IDS_RNAAP_TITLE,szOtherWindowTitle,255);
  385. HWND hwnd = FindWindow(szOtherWindowTitle, NULL);
  386. if (NULL != hwnd)
  387. {
  388. if (!PostMessage(hwnd, WM_CLOSE, 0, 0))
  389. {
  390. DEBUGMSG("Trying to kill RNAAP window returned getError %d", GetLastError());
  391. }
  392. }
  393. }
  394. // invoke the modem wizard UI to install the modem
  395. UINT uRet = InvokeModemWizard(hwndParent);
  396. if (uRet != ERROR_SUCCESS)
  397. {
  398. DisplayErrorMessage(hwndParent,IDS_ERRInstallModem,uRet,
  399. ERRCLS_STANDARD,MB_ICONEXCLAMATION);
  400. return ERROR_INVALID_PARAMETER;
  401. }
  402. if (FALSE == IsNT())
  403. {
  404. // Reload the RAS dlls now that the modem has been safely installed.
  405. InitRNA(hwndParent);
  406. }
  407. // Re-numerate the modems to be sure we have the most recent changes
  408. dwRet = EnumModem.ReInit();
  409. if (ERROR_SUCCESS != dwRet)
  410. {
  411. return dwRet;
  412. }
  413. // If there are still no modems, user cancelled
  414. if (0 == EnumModem.GetNumDevices())
  415. {
  416. return ERROR_CANCELLED;
  417. }
  418. else
  419. {
  420. // removed per GeoffR request 5-2-97
  421. //// 96/05/01 markdu ICW BUG 8049 Reboot if modem is installed.
  422. //fNeedsRestart = TRUE;
  423. }
  424. }
  425. else
  426. {
  427. //
  428. // 7/15/97 jmazner Olympus #6294
  429. // make sure TAPI location info is valid
  430. //
  431. InitTAPILocation(hwndParent);
  432. }
  433. }
  434. // tell caller whether we need to reboot or not
  435. if ((ERROR_SUCCESS == dwRet) && (lpfNeedsRestart))
  436. {
  437. *lpfNeedsRestart = fNeedsRestart;
  438. }
  439. // 4/2/97 ChrisK Olympus 209 2
  440. // Sanity check
  441. if (NULL != hwndWaitDlg)
  442. DestroyWindow(hwndWaitDlg);
  443. hwndWaitDlg = NULL;
  444. return dwRet;
  445. }
  446. //*******************************************************************
  447. //
  448. // FUNCTION: InetNeedSystemComponents
  449. //
  450. // PURPOSE: This function will check is components that are needed
  451. // for internet access (such as TCP/IP and RNA) are already
  452. // configured based the state of the options flags.
  453. //
  454. // PARAMETERS: dwfOptions - a combination of INETCFG_ flags that controls
  455. // the installation and configuration as follows:
  456. //
  457. // INETCFG_INSTALLRNA - install RNA (if needed)
  458. // INETCFG_INSTALLTCP - install TCP/IP (if needed)
  459. //
  460. // lpfNeedsConfig - On return, this will be
  461. // TRUE if system component(s)
  462. // should be installed
  463. //
  464. // RETURNS: HRESULT code, ERROR_SUCCESS if no errors occurred
  465. //
  466. // HISTORY: 05/02/97 VetriV Created.
  467. // 05/08/97 ChrisK Added INSTALLLAN, INSTALLDIALUP, and
  468. // INSTALLTCPONLY
  469. //
  470. //*******************************************************************
  471. extern "C" HRESULT WINAPI InetNeedSystemComponents(DWORD dwfOptions,
  472. LPBOOL lpbNeedsConfig)
  473. {
  474. DWORD dwRet = ERROR_SUCCESS;
  475. DEBUGMSG("export.cpp::InetNeedSystemComponents()");
  476. //
  477. // Validate parameters
  478. //
  479. if (!lpbNeedsConfig)
  480. {
  481. return ERROR_INVALID_PARAMETER;
  482. }
  483. //
  484. // Set up the install options
  485. //
  486. DWORD dwfInstallOptions = 0;
  487. if (dwfOptions & INETCFG_INSTALLTCP)
  488. {
  489. dwfInstallOptions |= ICFG_INSTALLTCP;
  490. }
  491. if (dwfOptions & INETCFG_INSTALLRNA)
  492. {
  493. dwfInstallOptions |= ICFG_INSTALLRAS;
  494. }
  495. //
  496. // ChrisK 5/8/97
  497. //
  498. if (dwfOptions & INETCFG_INSTALLLAN)
  499. {
  500. dwfInstallOptions |= ICFG_INSTALLLAN;
  501. }
  502. if (dwfOptions & INETCFG_INSTALLDIALUP)
  503. {
  504. dwfInstallOptions |= ICFG_INSTALLDIALUP;
  505. }
  506. if (dwfOptions & INETCFG_INSTALLTCPONLY)
  507. {
  508. dwfInstallOptions |= ICFG_INSTALLTCPONLY;
  509. }
  510. //
  511. // see if we need to install drivers
  512. //
  513. BOOL bNeedSysComponents = FALSE;
  514. dwRet = lpIcfgNeedInetComponents(dwfInstallOptions, &bNeedSysComponents);
  515. if (ERROR_SUCCESS != dwRet)
  516. {
  517. CHAR szErrorText[MAX_ERROR_TEXT+1]="";
  518. //
  519. // Get the text of the error message and display it.
  520. //
  521. if (lpIcfgGetLastInstallErrorText(szErrorText, MAX_ERROR_TEXT+1))
  522. {
  523. DEBUGMSG(szErrorText);
  524. }
  525. return dwRet;
  526. }
  527. *lpbNeedsConfig = bNeedSysComponents;
  528. return ERROR_SUCCESS;
  529. }
  530. //*******************************************************************
  531. //
  532. // FUNCTION: InetNeedModem
  533. //
  534. // PURPOSE: This function will check if modem is needed or not
  535. //
  536. // PARAMETERS: lpfNeedsConfig - On return, this will be
  537. // TRUE if modem
  538. // should be installed
  539. //
  540. // RETURNS: HRESULT code, ERROR_SUCCESS if no errors occurred
  541. //
  542. // HISTORY: 05/02/97 VetriV Created.
  543. //
  544. //*******************************************************************
  545. extern "C" HRESULT WINAPI InetNeedModem(LPBOOL lpbNeedsModem)
  546. {
  547. DWORD dwRet = ERROR_SUCCESS;
  548. //
  549. // Validate parameters
  550. //
  551. if (!lpbNeedsModem)
  552. {
  553. return ERROR_INVALID_PARAMETER;
  554. }
  555. if (TRUE == IsNT())
  556. {
  557. //
  558. // On NT call icfgnt.dll to determine if modem is needed
  559. //
  560. BOOL bNeedModem = FALSE;
  561. if (NULL == lpIcfgNeedModem)
  562. {
  563. return ERROR_GEN_FAILURE;
  564. }
  565. dwRet = (*lpIcfgNeedModem)(0, &bNeedModem);
  566. if (ERROR_SUCCESS != dwRet)
  567. {
  568. return dwRet;
  569. }
  570. *lpbNeedsModem = bNeedModem;
  571. return ERROR_SUCCESS;
  572. }
  573. else
  574. {
  575. //
  576. // Load RNA if not already loaded since ENUM_MODEM needs it.
  577. //
  578. dwRet = EnsureRNALoaded();
  579. if (ERROR_SUCCESS != dwRet)
  580. {
  581. return dwRet;
  582. }
  583. //
  584. // Enumerate the modems
  585. //
  586. ENUM_MODEM EnumModem;
  587. dwRet = EnumModem.GetError();
  588. if (ERROR_SUCCESS != dwRet)
  589. {
  590. return dwRet;
  591. }
  592. //
  593. // If there are no modems, we need to install one
  594. //
  595. if (0 == EnumModem.GetNumDevices())
  596. {
  597. *lpbNeedsModem = TRUE;
  598. }
  599. else
  600. {
  601. *lpbNeedsModem = FALSE;
  602. }
  603. return ERROR_SUCCESS;
  604. }
  605. }
  606. /*******************************************************************
  607. NAME: NeedDriversDlgProc
  608. SYNOPSIS: Dialog proc for installing drivers
  609. ********************************************************************/
  610. INT_PTR CALLBACK NeedDriversDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
  611. LPARAM lParam)
  612. {
  613. switch (uMsg)
  614. {
  615. case WM_INITDIALOG:
  616. // lParam contains pointer to NEEDDRIVERSDLGINFO struct, set it
  617. // in window data
  618. ASSERT(lParam);
  619. SetWindowLongPtr(hDlg,DWLP_USER,lParam);
  620. return NeedDriversDlgInit(hDlg,(PNEEDDRIVERSDLGINFO) lParam);
  621. break;
  622. case WM_COMMAND:
  623. switch (LOWORD(wParam))
  624. {
  625. case IDOK:
  626. {
  627. // get data pointer from window data
  628. PNEEDDRIVERSDLGINFO pNeedDriversDlgInfo =
  629. (PNEEDDRIVERSDLGINFO) GetWindowLongPtr(hDlg, DWLP_USER);
  630. ASSERT(pNeedDriversDlgInfo);
  631. // pass the data to the OK handler
  632. BOOL fRet=NeedDriversDlgOK(hDlg,pNeedDriversDlgInfo);
  633. EndDialog(hDlg,fRet);
  634. }
  635. break;
  636. case IDCANCEL:
  637. SetLastError(ERROR_CANCELLED);
  638. EndDialog(hDlg,FALSE);
  639. break;
  640. }
  641. break;
  642. }
  643. return FALSE;
  644. }
  645. /*******************************************************************
  646. NAME: NeedDriversDlgInit
  647. SYNOPSIS: proc to handle initialization of dialog for installing files
  648. ********************************************************************/
  649. BOOL NeedDriversDlgInit(HWND hDlg,PNEEDDRIVERSDLGINFO pNeedDriversDlgInfo)
  650. {
  651. ASSERT(pNeedDriversDlgInfo);
  652. // put the dialog in the center of the screen
  653. RECT rc;
  654. GetWindowRect(hDlg, &rc);
  655. SetWindowPos(hDlg, NULL,
  656. ((GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2),
  657. ((GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2),
  658. 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
  659. return TRUE;
  660. }
  661. /*******************************************************************
  662. NAME: NeedDriversDlgOK
  663. SYNOPSIS: OK handler for dialog for installing files
  664. ********************************************************************/
  665. BOOL NeedDriversDlgOK(HWND hDlg,PNEEDDRIVERSDLGINFO pNeedDriversDlgInfo)
  666. {
  667. ASSERT(pNeedDriversDlgInfo);
  668. // set the dialog text to "Installing files..." to give feedback to
  669. // user
  670. CHAR szMsg[MAX_RES_LEN+1];
  671. LoadSz(IDS_INSTALLING_FILES,szMsg,sizeof(szMsg));
  672. SetDlgItemText(hDlg,IDC_TX_STATUS,szMsg);
  673. // disable buttons & dialog so it can't get focus
  674. EnableDlg(hDlg, FALSE);
  675. // install the drivers we need
  676. DWORD dwRet = lpIcfgInstallInetComponents(hDlg,
  677. pNeedDriversDlgInfo->dwfOptions,
  678. pNeedDriversDlgInfo->lpfNeedsRestart);
  679. if (ERROR_SUCCESS != dwRet)
  680. {
  681. //
  682. // Don't display error message if user cancelled
  683. //
  684. if (ERROR_CANCELLED != dwRet)
  685. {
  686. CHAR szErrorText[MAX_ERROR_TEXT+1]="";
  687. // Get the text of the error message and display it.
  688. if (lpIcfgGetLastInstallErrorText(szErrorText, MAX_ERROR_TEXT+1))
  689. {
  690. MsgBoxSz(NULL,szErrorText,MB_ICONEXCLAMATION,MB_OK);
  691. }
  692. }
  693. // Enable the dialog again
  694. EnableDlg(hDlg, TRUE);
  695. SetLastError(dwRet);
  696. return FALSE;
  697. }
  698. // Enable the dialog again
  699. EnableDlg(hDlg, TRUE);
  700. return TRUE;
  701. }
  702. /*******************************************************************
  703. NAME: EnableDlg
  704. SYNOPSIS: Enables or disables the dlg buttons and the dlg
  705. itself (so it can't receive focus)
  706. ********************************************************************/
  707. VOID EnableDlg(HWND hDlg,BOOL fEnable)
  708. {
  709. // disable/enable ok and cancel buttons
  710. EnableWindow(GetDlgItem(hDlg,IDOK),fEnable);
  711. EnableWindow(GetDlgItem(hDlg,IDCANCEL),fEnable);
  712. // disable/enable dlg
  713. EnableWindow(hDlg,fEnable);
  714. UpdateWindow(hDlg);
  715. }
  716. //+----------------------------------------------------------------------------
  717. // Function InetStartServices
  718. //
  719. // Synopsis This function guarentees that RAS services are running
  720. //
  721. // Arguments none
  722. //
  723. // Return ERROR_SUCCESS - if the services are enabled and running
  724. //
  725. // History 10/16/96 ChrisK Created
  726. //-----------------------------------------------------------------------------
  727. extern "C" HRESULT WINAPI InetStartServices()
  728. {
  729. ASSERT(lpIcfgStartServices);
  730. if (NULL == lpIcfgStartServices)
  731. return ERROR_GEN_FAILURE;
  732. return (lpIcfgStartServices());
  733. }
  734. #if !defined(WIN16)
  735. // 4/1/97 ChrisK Olympus 209
  736. //+----------------------------------------------------------------------------
  737. //
  738. // Function GetOSMajorVersion
  739. //
  740. // Synopsis Get the Major version number of Operating system
  741. //
  742. // Arguments None
  743. //
  744. // Returns Major version Number of OS
  745. //
  746. // History 2/19/98 VetriV Created
  747. //
  748. //-----------------------------------------------------------------------------
  749. DWORD GetOSMajorVersion(void)
  750. {
  751. static dwMajorVersion = 0;
  752. OSVERSIONINFO oviVersion;
  753. if (0 != dwMajorVersion)
  754. {
  755. return dwMajorVersion;
  756. }
  757. ZeroMemory(&oviVersion,sizeof(oviVersion));
  758. oviVersion.dwOSVersionInfoSize = sizeof(oviVersion);
  759. GetVersionEx(&oviVersion);
  760. dwMajorVersion = oviVersion.dwMajorVersion;
  761. return dwMajorVersion;
  762. }
  763. #endif //!WIN16