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

1347 lines
41 KiB

  1. // Import.cpp: implementation of the CISPImport class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. //#include "stdafx.h"
  5. //#include "appdefs.h"
  6. //#include "icwhelp.h"
  7. #include "import.h"
  8. #include "rnaapi.h"
  9. #ifdef DBG
  10. #undef THIS_FILE
  11. static CHAR THIS_FILE[]=__FILE__;
  12. #define new DEBUG_NEW
  13. #endif
  14. #pragma data_seg(".rdata")
  15. WCHAR cszEntrySection[] = L"Entry";
  16. WCHAR cszAlias[] = L"Import_Name";
  17. WCHAR cszML[] = L"Multilink";
  18. WCHAR cszPhoneSection[] = L"Phone";
  19. WCHAR cszDialAsIs[] = L"Dial_As_Is";
  20. WCHAR cszPhone[] = L"Phone_Number";
  21. WCHAR cszISDN[] = L"ISDN_Number";
  22. WCHAR cszAreaCode[] = L"Area_Code";
  23. WCHAR cszCountryCode[] = L"Country_Code";
  24. WCHAR cszCountryID[] = L"Country_ID";
  25. WCHAR cszDeviceSection[] = L"Device";
  26. WCHAR cszDeviceType[] = L"Type";
  27. WCHAR cszDeviceName[] = L"Name";
  28. WCHAR cszDevCfgSize[] = L"Settings_Size";
  29. WCHAR cszDevCfg[] = L"Settings";
  30. WCHAR cszServerSection[] = L"Server";
  31. WCHAR cszServerType[] = L"Type";
  32. WCHAR cszSWCompress[] = L"SW_Compress";
  33. WCHAR cszPWEncrypt[] = L"PW_Encrypt";
  34. WCHAR cszNetLogon[] = L"Network_Logon";
  35. WCHAR cszSWEncrypt[] = L"SW_Encrypt";
  36. WCHAR cszNetBEUI[] = L"Negotiate_NetBEUI";
  37. WCHAR cszIPX[] = L"Negotiate_IPX/SPX";
  38. WCHAR cszIP[] = L"Negotiate_TCP/IP";
  39. WCHAR cszDisableLcp[] = L"Disable_LCP";
  40. WCHAR cszIPSection[] = L"TCP/IP";
  41. WCHAR cszIPSpec[] = L"Specify_IP_Address";
  42. WCHAR cszIPAddress[] = L"IP_address";
  43. WCHAR cszServerSpec[] = L"Specify_Server_Address";
  44. WCHAR cszDNSAddress[] = L"DNS_address";
  45. WCHAR cszDNSAltAddress[] = L"DNS_Alt_address";
  46. WCHAR cszWINSAddress[] = L"WINS_address";
  47. WCHAR cszWINSAltAddress[] = L"WINS_Alt_address";
  48. WCHAR cszIPCompress[] = L"IP_Header_Compress";
  49. WCHAR cszWanPri[] = L"Gateway_On_Remote";
  50. WCHAR cszMLSection[] = L"Multilink";
  51. WCHAR cszLinkIndex[] = L"Line_%s";
  52. WCHAR cszScriptingSection[] = L"Scripting";
  53. WCHAR cszScriptName[] = L"Name";
  54. WCHAR cszScriptSection[] = L"Script_File";
  55. WCHAR cszYes[] = L"yes";
  56. WCHAR cszNo[] = L"no";
  57. WCHAR cszUserSection[] = L"User";
  58. WCHAR cszUserName[] = L"Name";
  59. WCHAR cszPassword[] = L"Password";
  60. WCHAR szNull[] = L"";
  61. WCHAR cszSupport[] = L"Support";
  62. WCHAR cszSupportNumber[] = L"SupportPhoneNumber";
  63. SERVER_TYPES aServerTypes[] =
  64. {
  65. {L"PPP", RASFP_Ppp, 0 },
  66. {L"SLIP", RASFP_Slip, 0 },
  67. {L"CSLIP", RASFP_Slip, RASEO_IpHeaderCompression },
  68. {L"RAS", RASFP_Ras, 0 }
  69. };
  70. #pragma data_seg()
  71. WCHAR g_szDeviceName[RAS_MaxDeviceName + 1] = L"\0"; //holds the user's modem choice when multiple
  72. WCHAR g_szDeviceType[RAS_MaxDeviceType + 1] = L"\0"; // modems are installed
  73. #define ISIGNUP_KEY L"Software\\Microsoft\\ISIGNUP"
  74. #define DEVICENAMEKEY L"DeviceName"
  75. #define DEVICETYPEKEY L"DeviceType"
  76. static const WCHAR cszInetcfg[] = L"Inetcfg.dll";
  77. static const CHAR cszSetAutoProxyConnectoid[] = "SetAutoProxyConnectoid";
  78. typedef HRESULT (WINAPI * SETAUTOPROXYCONNECTOID) (IN BOOL bEnable);
  79. extern int FIsDigit( int c );
  80. //////////////////////////////////////////////////////////////////////
  81. // Construction/Destruction
  82. //////////////////////////////////////////////////////////////////////
  83. CISPImport::CISPImport()
  84. {
  85. m_szDeviceName[0] = L'\0';
  86. m_szDeviceType[0] = L'\0';
  87. m_szConnectoidName[0] = L'\0';
  88. m_bIsISDNDevice = FALSE;
  89. }
  90. CISPImport::~CISPImport()
  91. {
  92. // Clean up the registry
  93. DeleteUserDeviceSelection(DEVICENAMEKEY);
  94. DeleteUserDeviceSelection(DEVICETYPEKEY);
  95. }
  96. //+----------------------------------------------------------------------------
  97. // DWORD NEAR PASCAL StrToip (LPWSTR szIPAddress, LPDWORD lpdwAddr)
  98. //
  99. // This function converts a IP address string to an IP address structure.
  100. //
  101. // History:
  102. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  103. // Cloned from SMMSCRPT.
  104. // 1/9/98 DONALDM adapted from ICWCONN1
  105. //+----------------------------------------------------------------------------
  106. LPCWSTR NEAR PASCAL StrToSubip (LPCWSTR szIPAddress, LPBYTE pVal)
  107. {
  108. LPCWSTR pszIP = szIPAddress;
  109. *pVal = (BYTE)Sz2W(pszIP);
  110. // skip over digits
  111. while (FIsDigit(*pszIP))
  112. {
  113. ++pszIP;
  114. }
  115. // skip over one or more separators
  116. while (*pszIP && !FIsDigit(*pszIP))
  117. {
  118. ++pszIP;
  119. }
  120. return pszIP;
  121. }
  122. DWORD NEAR PASCAL StrToip (LPCWSTR szIPAddress, RASIPADDR FAR *ipAddr)
  123. {
  124. LPCWSTR pszIP = szIPAddress;
  125. pszIP = StrToSubip(pszIP, &ipAddr->a);
  126. pszIP = StrToSubip(pszIP, &ipAddr->b);
  127. pszIP = StrToSubip(pszIP, &ipAddr->c);
  128. pszIP = StrToSubip(pszIP, &ipAddr->d);
  129. return ERROR_SUCCESS;
  130. }
  131. //****************************************************************************
  132. // DWORD NEAR PASCAL ImportPhoneInfo(PPHONENUM ppn, LPCWSTR szFileName)
  133. //
  134. // This function imports the phone number.
  135. //
  136. // History:
  137. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  138. // Created.
  139. //****************************************************************************
  140. DWORD NEAR PASCAL ImportPhoneInfo(LPRASENTRY lpRasEntry, LPCWSTR szFileName, BOOL bISDN)
  141. {
  142. WCHAR szYesNo[MAXNAME];
  143. if (!GetPrivateProfileString(cszPhoneSection,
  144. (bISDN ? cszISDN : cszPhone),
  145. szNull,
  146. lpRasEntry->szLocalPhoneNumber,
  147. MAX_CHARS_IN_BUFFER(lpRasEntry->szLocalPhoneNumber),
  148. szFileName))
  149. {
  150. // If the ISDN_Number is empty, we read from the Phone_Number
  151. GetPrivateProfileString(cszPhoneSection,
  152. cszPhone,
  153. DUN_NOPHONENUMBER,
  154. lpRasEntry->szLocalPhoneNumber,
  155. MAX_CHARS_IN_BUFFER(lpRasEntry->szLocalPhoneNumber),
  156. szFileName);
  157. }
  158. lpRasEntry->dwfOptions &= ~RASEO_UseCountryAndAreaCodes;
  159. GetPrivateProfileString(cszPhoneSection,
  160. cszDialAsIs,
  161. cszYes,
  162. szYesNo,
  163. MAX_CHARS_IN_BUFFER(szYesNo),
  164. szFileName);
  165. // Do we have to get country code and area code?
  166. //
  167. if (!lstrcmpi(szYesNo, cszNo))
  168. {
  169. // If we cannot get the country ID or it is zero, default to dial as is
  170. //
  171. if ((lpRasEntry->dwCountryID = GetPrivateProfileInt(cszPhoneSection,
  172. cszCountryID,
  173. 0,
  174. szFileName)) != 0)
  175. {
  176. lpRasEntry->dwCountryCode = GetPrivateProfileInt(cszPhoneSection,
  177. cszCountryCode,
  178. 1,
  179. szFileName);
  180. if (GetPrivateProfileString(cszPhoneSection,
  181. cszAreaCode,
  182. szNull,
  183. lpRasEntry->szAreaCode,
  184. MAX_CHARS_IN_BUFFER(lpRasEntry->szAreaCode),
  185. szFileName) != 0)
  186. {
  187. lpRasEntry->dwfOptions |= RASEO_UseCountryAndAreaCodes;
  188. }
  189. }
  190. }
  191. return ERROR_SUCCESS;
  192. }
  193. //****************************************************************************
  194. // DWORD NEAR PASCAL ImportServerInfo(PSMMINFO psmmi, LPWSTR szFileName)
  195. //
  196. // This function imports the server type name and settings.
  197. //
  198. // History:
  199. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  200. // Created.
  201. //****************************************************************************
  202. DWORD NEAR PASCAL ImportServerInfo(LPRASENTRY lpRasEntry, LPCWSTR szFileName)
  203. {
  204. WCHAR szYesNo[MAXNAME];
  205. WCHAR szType[MAXNAME];
  206. DWORD i;
  207. // Get the server type name
  208. //
  209. GetPrivateProfileString(cszServerSection,
  210. cszServerType,
  211. szNull,
  212. szType,
  213. MAX_CHARS_IN_BUFFER(szType),
  214. szFileName);
  215. // need to convert the string into
  216. // one of the following values
  217. // RASFP_Ppp
  218. // RASFP_Slip Note CSLIP is SLIP with IP compression on
  219. // RASFP_Ras
  220. for (i = 0; i < NUM_SERVER_TYPES; ++i)
  221. {
  222. if (!lstrcmpi(aServerTypes[i].szType, szType))
  223. {
  224. lpRasEntry->dwFramingProtocol = aServerTypes[i].dwType;
  225. lpRasEntry->dwfOptions |= aServerTypes[i].dwfOptions;
  226. break;
  227. }
  228. }
  229. // Get the server type settings
  230. //
  231. if (GetPrivateProfileString(cszServerSection,
  232. cszSWCompress,
  233. szNull,
  234. szYesNo,
  235. MAX_CHARS_IN_BUFFER(szYesNo),
  236. szFileName))
  237. {
  238. if (!lstrcmpi(szYesNo, cszNo))
  239. {
  240. lpRasEntry->dwfOptions &= ~RASEO_SwCompression;
  241. }
  242. else
  243. {
  244. lpRasEntry->dwfOptions |= RASEO_SwCompression;
  245. };
  246. };
  247. if (GetPrivateProfileString(cszServerSection,
  248. cszPWEncrypt,
  249. szNull,
  250. szYesNo,
  251. MAX_CHARS_IN_BUFFER(szYesNo),
  252. szFileName))
  253. {
  254. if (!lstrcmpi(szYesNo, cszNo))
  255. {
  256. lpRasEntry->dwfOptions &= ~RASEO_RequireEncryptedPw;
  257. }
  258. else
  259. {
  260. lpRasEntry->dwfOptions |= RASEO_RequireEncryptedPw;
  261. };
  262. };
  263. if (GetPrivateProfileString(cszServerSection,
  264. cszNetLogon,
  265. szNull,
  266. szYesNo,
  267. MAX_CHARS_IN_BUFFER(szYesNo),
  268. szFileName))
  269. {
  270. if (!lstrcmpi(szYesNo, cszNo))
  271. {
  272. lpRasEntry->dwfOptions &= ~RASEO_NetworkLogon;
  273. }
  274. else
  275. {
  276. lpRasEntry->dwfOptions |= RASEO_NetworkLogon;
  277. };
  278. };
  279. if (GetPrivateProfileString(cszServerSection,
  280. cszSWEncrypt,
  281. szNull,
  282. szYesNo,
  283. MAX_CHARS_IN_BUFFER(szYesNo),
  284. szFileName))
  285. {
  286. if (!lstrcmpi(szYesNo, cszNo))
  287. {
  288. lpRasEntry->dwfOptions &= ~RASEO_RequireDataEncryption;
  289. }
  290. else
  291. {
  292. lpRasEntry->dwfOptions |= RASEO_RequireDataEncryption;
  293. };
  294. };
  295. // Get the protocol settings
  296. //
  297. if (GetPrivateProfileString(cszServerSection,
  298. cszNetBEUI,
  299. szNull,
  300. szYesNo,
  301. MAX_CHARS_IN_BUFFER(szYesNo),
  302. szFileName))
  303. {
  304. if (!lstrcmpi(szYesNo, cszNo))
  305. {
  306. lpRasEntry->dwfNetProtocols &= ~RASNP_NetBEUI;
  307. }
  308. else
  309. {
  310. lpRasEntry->dwfNetProtocols |= RASNP_NetBEUI;
  311. };
  312. };
  313. if (GetPrivateProfileString(cszServerSection,
  314. cszIPX,
  315. szNull,
  316. szYesNo,
  317. MAX_CHARS_IN_BUFFER(szYesNo),
  318. szFileName))
  319. {
  320. if (!lstrcmpi(szYesNo, cszNo))
  321. {
  322. lpRasEntry->dwfNetProtocols &= ~RASNP_Ipx;
  323. }
  324. else
  325. {
  326. lpRasEntry->dwfNetProtocols |= RASNP_Ipx;
  327. };
  328. };
  329. if (GetPrivateProfileString(cszServerSection,
  330. cszIP,
  331. szNull,
  332. szYesNo,
  333. MAX_CHARS_IN_BUFFER(szYesNo),
  334. szFileName))
  335. {
  336. if (!lstrcmpi(szYesNo, cszNo))
  337. {
  338. lpRasEntry->dwfNetProtocols &= ~RASNP_Ip;
  339. }
  340. else
  341. {
  342. lpRasEntry->dwfNetProtocols |= RASNP_Ip;
  343. };
  344. };
  345. if (GetPrivateProfileString(cszServerSection,
  346. cszDisableLcp,
  347. szNull,
  348. szYesNo,
  349. MAX_CHARS_IN_BUFFER(szYesNo),
  350. szFileName))
  351. {
  352. if (!lstrcmpi(szYesNo, cszYes))
  353. {
  354. lpRasEntry->dwfOptions |= RASEO_DisableLcpExtensions;
  355. }
  356. else
  357. {
  358. lpRasEntry->dwfOptions &= ~RASEO_DisableLcpExtensions;
  359. }
  360. };
  361. return ERROR_SUCCESS;
  362. }
  363. //****************************************************************************
  364. // DWORD NEAR PASCAL ImportIPInfo(LPWSTR szEntryName, LPWSTR szFileName)
  365. //
  366. // This function imports the TCP/IP information
  367. //
  368. // History:
  369. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  370. // Created.
  371. //****************************************************************************
  372. DWORD NEAR PASCAL ImportIPInfo(LPRASENTRY lpRasEntry, LPCWSTR szFileName)
  373. {
  374. WCHAR szIPAddr[MAXIPADDRLEN];
  375. WCHAR szYesNo[MAXNAME];
  376. // Import IP address information
  377. //
  378. if (GetPrivateProfileString(cszIPSection,
  379. cszIPSpec,
  380. szNull,
  381. szYesNo,
  382. MAX_CHARS_IN_BUFFER(szYesNo),
  383. szFileName))
  384. {
  385. if (!lstrcmpi(szYesNo, cszYes))
  386. {
  387. // The import file has IP address specified, get the IP address
  388. //
  389. lpRasEntry->dwfOptions |= RASEO_SpecificIpAddr;
  390. if (GetPrivateProfileString(cszIPSection,
  391. cszIPAddress,
  392. szNull,
  393. szIPAddr,
  394. MAX_CHARS_IN_BUFFER(szIPAddr),
  395. szFileName))
  396. {
  397. StrToip (szIPAddr, &lpRasEntry->ipaddr);
  398. };
  399. }
  400. else
  401. {
  402. lpRasEntry->dwfOptions &= ~RASEO_SpecificIpAddr;
  403. };
  404. };
  405. // Import Server address information
  406. //
  407. if (GetPrivateProfileString(cszIPSection,
  408. cszServerSpec,
  409. szNull,
  410. szYesNo,
  411. MAX_CHARS_IN_BUFFER(szYesNo),
  412. szFileName))
  413. {
  414. if (!lstrcmpi(szYesNo, cszYes))
  415. {
  416. // The import file has server address specified, get the server address
  417. //
  418. lpRasEntry->dwfOptions |= RASEO_SpecificNameServers;
  419. if (GetPrivateProfileString(cszIPSection,
  420. cszDNSAddress,
  421. szNull,
  422. szIPAddr,
  423. MAX_CHARS_IN_BUFFER(szIPAddr),
  424. szFileName))
  425. {
  426. StrToip (szIPAddr, &lpRasEntry->ipaddrDns);
  427. };
  428. if (GetPrivateProfileString(cszIPSection,
  429. cszDNSAltAddress,
  430. szNull,
  431. szIPAddr,
  432. MAX_CHARS_IN_BUFFER(szIPAddr),
  433. szFileName))
  434. {
  435. StrToip (szIPAddr, &lpRasEntry->ipaddrDnsAlt);
  436. };
  437. if (GetPrivateProfileString(cszIPSection,
  438. cszWINSAddress,
  439. szNull,
  440. szIPAddr,
  441. MAX_CHARS_IN_BUFFER(szIPAddr),
  442. szFileName))
  443. {
  444. StrToip (szIPAddr, &lpRasEntry->ipaddrWins);
  445. };
  446. if (GetPrivateProfileString(cszIPSection,
  447. cszWINSAltAddress,
  448. szNull,
  449. szIPAddr,
  450. MAX_CHARS_IN_BUFFER(szIPAddr),
  451. szFileName))
  452. {
  453. StrToip (szIPAddr, &lpRasEntry->ipaddrWinsAlt);
  454. };
  455. }
  456. else
  457. {
  458. lpRasEntry->dwfOptions &= ~RASEO_SpecificNameServers;
  459. };
  460. };
  461. // Header compression and the gateway settings
  462. //
  463. if (GetPrivateProfileString(cszIPSection,
  464. cszIPCompress,
  465. szNull,
  466. szYesNo,
  467. MAX_CHARS_IN_BUFFER(szYesNo),
  468. szFileName))
  469. {
  470. if (!lstrcmpi(szYesNo, cszNo))
  471. {
  472. lpRasEntry->dwfOptions &= ~RASEO_IpHeaderCompression;
  473. }
  474. else
  475. {
  476. lpRasEntry->dwfOptions |= RASEO_IpHeaderCompression;
  477. };
  478. };
  479. if (GetPrivateProfileString(cszIPSection,
  480. cszWanPri,
  481. szNull,
  482. szYesNo,
  483. MAX_CHARS_IN_BUFFER(szYesNo),
  484. szFileName))
  485. {
  486. if (!lstrcmpi(szYesNo, cszNo))
  487. {
  488. lpRasEntry->dwfOptions &= ~RASEO_RemoteDefaultGateway;
  489. }
  490. else
  491. {
  492. lpRasEntry->dwfOptions |= RASEO_RemoteDefaultGateway;
  493. };
  494. };
  495. return ERROR_SUCCESS;
  496. }
  497. //****************************************************************************
  498. // HANDLE NEAR PASCAL CreateUniqueFile(LPWSTR szPath, LPWSTR szFile)
  499. //
  500. // This function creates a unique file. If the file already exists, it will
  501. // try to create a file with similar name and return the name.
  502. //
  503. // History:
  504. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  505. // Created.
  506. //****************************************************************************
  507. HANDLE NEAR PASCAL CreateUniqueFile(LPWSTR szPath, LPWSTR szScript)
  508. {
  509. HANDLE hFile;
  510. LPWSTR pszSuffix, lpsz;
  511. UINT uSuffix;
  512. pszSuffix = szPath + lstrlen(szPath);
  513. lpsz = CharPrev(szPath, pszSuffix);
  514. if (*lpsz != L'\\')
  515. {
  516. *pszSuffix = L'\\';
  517. pszSuffix++;
  518. };
  519. lstrcpy(pszSuffix, szScript);
  520. // Try the specified filename
  521. //
  522. hFile = CreateFile(szPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
  523. FILE_ATTRIBUTE_NORMAL, NULL);
  524. // If the file exists
  525. //
  526. if ((hFile == INVALID_HANDLE_VALUE) && (GetLastError() == ERROR_FILE_EXISTS))
  527. {
  528. WCHAR szNewName[MAX_PATH];
  529. // Need to copy it to another name in the same directory
  530. //
  531. if (LoadString(NULL, IDS_DEFAULT_SCP, szNewName, MAX_CHARS_IN_BUFFER(szNewName)))
  532. {
  533. // Increment the file index until a non-duplicated file can be created
  534. //
  535. uSuffix = 0;
  536. do
  537. {
  538. wsprintf(pszSuffix, szNewName, uSuffix);
  539. uSuffix++;
  540. hFile = CreateFile(szPath, GENERIC_WRITE, 0, NULL, CREATE_NEW,
  541. FILE_ATTRIBUTE_NORMAL, NULL);
  542. }
  543. while ((hFile == INVALID_HANDLE_VALUE) &&
  544. (GetLastError() == ERROR_FILE_EXISTS) &&
  545. (uSuffix < 0x0000FFFF));
  546. };
  547. };
  548. // If we do not have the file, reserve the pathname
  549. //
  550. if (hFile == INVALID_HANDLE_VALUE)
  551. {
  552. *pszSuffix = L'\0';
  553. };
  554. return hFile;
  555. }
  556. //****************************************************************************
  557. // HANDLE NEAR PASCAL CreateScriptFile(LPWSTR szScript, LPWSTR szImportFile)
  558. //
  559. // This function creates the script file
  560. //
  561. // History:
  562. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  563. // Created.
  564. //****************************************************************************
  565. HANDLE NEAR PASCAL CreateScriptFile(LPWSTR szScript, LPCWSTR szImportFile)
  566. {
  567. LPWSTR pszPath, pszShortName;
  568. LPWSTR pszDir;
  569. DWORD cb;
  570. HANDLE hFile;
  571. // Assume failure
  572. //
  573. hFile = INVALID_HANDLE_VALUE;
  574. // Allocate a buffer for pathname
  575. //
  576. if ((pszPath = (LPWSTR)GlobalAlloc(GPTR, (2*MAX_PATH)*sizeof(WCHAR))) == NULL)
  577. {
  578. ////TraceMsg(TF_GENERAL, L"CONNECT:CreateScriptFile(): Local Alloc failed\n");
  579. return hFile;
  580. }
  581. pszShortName = pszPath+MAX_PATH;
  582. // Get the default directory
  583. //
  584. if (GetWindowsDirectory(pszPath, MAX_PATH) != 0)
  585. {
  586. // Get the Windows drive
  587. //
  588. pszDir = pszPath;
  589. while((*pszDir != L'\\') && (*pszDir != L'\0'))
  590. {
  591. pszDir = CharNext(pszDir);
  592. };
  593. // Did we find Windows drive?
  594. //
  595. if (*pszDir != L'\0')
  596. {
  597. // Prepare the drive
  598. //
  599. cb = (DWORD)(pszDir - pszPath);
  600. MyMemCpy((LPBYTE) szScript, (const LPBYTE) pszPath, (size_t) cb);
  601. pszDir = szScript + cb;
  602. // Get the script filename
  603. //
  604. if (GetPrivateProfileString(cszScriptingSection,
  605. cszScriptName,
  606. szNull,
  607. pszShortName,
  608. MAX_PATH,
  609. szImportFile) != 0)
  610. {
  611. // Try the favorite script directory
  612. //
  613. if (LoadString(NULL, IDS_INI_SCRIPT_DIR, pszDir,
  614. (MAX_PATH - cb)) != 0)
  615. {
  616. // Try creating the file
  617. //
  618. hFile = CreateUniqueFile(szScript, pszShortName);
  619. };
  620. // If we do not have the file yet, try the second favorite
  621. //
  622. if (hFile == INVALID_HANDLE_VALUE)
  623. {
  624. if (LoadString(NULL/*_Module.GetModuleInstance()*/, IDS_INI_SCRIPT_SHORTDIR, pszDir,
  625. (MAX_PATH - cb)))
  626. {
  627. // Try creating the file
  628. //
  629. hFile = CreateUniqueFile(szScript, pszShortName);
  630. };
  631. };
  632. // If we do not have the file yet, try Windows directory
  633. //
  634. if (hFile == INVALID_HANDLE_VALUE)
  635. {
  636. // Get original Windows directory
  637. //
  638. lstrcpy(szScript, pszPath);
  639. // Try one more time
  640. //
  641. hFile = CreateUniqueFile(szScript, pszShortName);
  642. };
  643. };
  644. };
  645. };
  646. GlobalFree(pszPath);
  647. return hFile;
  648. }
  649. //****************************************************************************
  650. // DWORD NEAR PASCAL ImportScriptFile(LPWSTR szEntryName, LPWSTR szImportFile)
  651. //
  652. // This function imports the script file
  653. //
  654. // History:
  655. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  656. // Created.
  657. //****************************************************************************
  658. DWORD NEAR PASCAL ImportScriptFile(LPRASENTRY lpRasEntry, LPCWSTR szImportFile)
  659. {
  660. HANDLE hfScript;
  661. LPWSTR pszLine;
  662. LPWSTR pszFile;
  663. int i, iMaxLine = 0;
  664. UINT cbSize, cbRet;
  665. WCHAR szTmp[4];
  666. DWORD dwRet;
  667. dwRet=ERROR_SUCCESS;
  668. // If a script section does not exist, do nothing
  669. //
  670. if (GetPrivateProfileString(cszScriptingSection,
  671. cszScriptName,
  672. szNull,
  673. szTmp,
  674. MAX_CHARS_IN_BUFFER(szTmp),
  675. szImportFile) == 0)
  676. {
  677. return ERROR_SUCCESS;
  678. };
  679. // Allocate a buffer for the script lines
  680. //
  681. if ((pszLine = (LPWSTR)GlobalAlloc(LMEM_FIXED, (SIZE_ReadBuf+MAX_PATH)*sizeof(WCHAR)))
  682. == NULL)
  683. {
  684. //TraceMsg(TF_GENERAL, L"CONNECT:ImportScriptFile(): Local Alloc failed\n");
  685. return ERROR_OUTOFMEMORY;
  686. }
  687. // Look for script
  688. //
  689. if (GetPrivateProfileString(cszScriptSection,
  690. NULL,
  691. szNull,
  692. pszLine,
  693. SIZE_ReadBuf,
  694. szImportFile) != 0)
  695. {
  696. // Get the maximum line number
  697. //
  698. pszFile = pszLine;
  699. iMaxLine = -1;
  700. while (*pszFile)
  701. {
  702. i = Sz2W(pszFile);
  703. iMaxLine = max(iMaxLine, i);
  704. pszFile += lstrlen(pszFile)+1;
  705. };
  706. // If we have at least one line, we will import the script file
  707. //
  708. if (iMaxLine >= 0)
  709. {
  710. pszFile = pszLine+SIZE_ReadBuf;
  711. // Create the script file
  712. //
  713. //DebugBreak();
  714. hfScript = CreateScriptFile(pszFile, szImportFile);
  715. //TraceMsg(TF_GENERAL, "CONNECT:ImportScriptFile(): CreateScriptFile hfScript %d, %s, %s\n", hfScript, pszFile,szImportFile);
  716. if (hfScript != INVALID_HANDLE_VALUE)
  717. {
  718. WCHAR szLineNum[MAXLONGLEN+1];
  719. // From The first line to the last line
  720. //
  721. for (i = 0; i <= iMaxLine; i++)
  722. {
  723. // Read the script line
  724. //
  725. wsprintf(szLineNum, L"%d", i);
  726. if ((cbSize = GetPrivateProfileString(cszScriptSection,
  727. szLineNum,
  728. szNull,
  729. pszLine,
  730. SIZE_ReadBuf,
  731. szImportFile)) != 0)
  732. {
  733. // Write to the script file
  734. //
  735. lstrcat(pszLine, L"\x0d\x0a");
  736. WriteFile(hfScript, pszLine, cbSize+2, (LPDWORD)&cbRet, NULL);
  737. };
  738. };
  739. CloseHandle(hfScript);
  740. // Associate it with the phonebook entry
  741. //
  742. lstrcpyn(lpRasEntry->szScript, pszFile, RAS_MaxEntryName);
  743. }
  744. else
  745. {
  746. dwRet = GetLastError();
  747. };
  748. }
  749. else
  750. {
  751. dwRet = ERROR_PATH_NOT_FOUND;
  752. };
  753. }
  754. else
  755. {
  756. dwRet = ERROR_PATH_NOT_FOUND;
  757. };
  758. GlobalFree(pszLine);
  759. return dwRet;
  760. }
  761. //****************************************************************************
  762. // DWORD WINAPI RnaValidateImportEntry (LPWSTR)
  763. //
  764. // This function is called to validate an importable file
  765. //
  766. // History:
  767. // Wed 03-Jan-1996 09:45:01 -by- Viroon Touranachun [viroont]
  768. // Created.
  769. //****************************************************************************
  770. DWORD CISPImport::RnaValidateImportEntry (LPCWSTR szFileName)
  771. {
  772. WCHAR szTmp[4];
  773. // Get the alias entry name
  774. //
  775. return (GetPrivateProfileString(cszEntrySection,
  776. cszEntry_Name,
  777. szNull,
  778. szTmp,
  779. MAX_CHARS_IN_BUFFER(szTmp),
  780. szFileName) > 0 ?
  781. ERROR_SUCCESS : ERROR_CORRUPT_PHONEBOOK);
  782. }
  783. //****************************************************************************
  784. // HRESULT ImportConnection (LPCWSTR szFileName, LPWSTR pszEntryName, LPWSTR pszUserName, LPWSTR pszPassword)
  785. //
  786. // This function is called to import an entry from a specified file
  787. //
  788. // History:
  789. // Mon 18-Dec-1995 10:07:02 -by- Viroon Touranachun [viroont]
  790. // Created.
  791. // Sat 16-Mar-1996 10:01:00 -by- Chris Kauffman [chrisk]
  792. // Modified to return HRESULT and load DLL dynamically
  793. //****************************************************************************
  794. HRESULT CISPImport::ImportConnection (LPCWSTR szFileName, LPWSTR pszSupportNumber, LPWSTR pszEntryName, LPWSTR pszUserName, LPWSTR pszPassword, LPBOOL pfNeedsRestart)
  795. {
  796. LPRASENTRY lpRasEntry;
  797. DWORD dwRet;
  798. DWORD dwOptions;
  799. //HINSTANCE hinetcfg;
  800. //FARPROC fp, fpSetAutoProxy;
  801. RNAAPI Rnaapi;
  802. // Get the size of device configuration
  803. // This also validates an exported file
  804. //
  805. if ((dwRet = RnaValidateImportEntry(szFileName)) != ERROR_SUCCESS)
  806. {
  807. return dwRet;
  808. };
  809. // Allocate a buffer for entry and device config
  810. //
  811. if ((lpRasEntry = (LPRASENTRY)GlobalAlloc(GPTR, sizeof(RASENTRY))) == NULL)
  812. {
  813. return ERROR_OUTOFMEMORY;
  814. };
  815. // Get the entry name
  816. // Need to find a good name for it and remember it as an alias
  817. //
  818. GetPrivateProfileString(cszEntrySection,
  819. cszEntry_Name,
  820. szNull,
  821. pszEntryName,
  822. RAS_MaxEntryName+1,
  823. szFileName);
  824. GetPrivateProfileString(cszUserSection,
  825. cszUserName,
  826. szNull,
  827. pszUserName,
  828. UNLEN+1,
  829. szFileName);
  830. GetPrivateProfileString(cszUserSection,
  831. cszPassword,
  832. szNull,
  833. pszPassword,
  834. PWLEN+1,
  835. szFileName);
  836. // Get ISP support number
  837. //
  838. GetPrivateProfileString(cszSupport,
  839. cszSupportNumber,
  840. szNull,
  841. pszSupportNumber,
  842. RAS_MaxAreaCode + RAS_MaxPhoneNumber +1,
  843. szFileName);
  844. // Get device name, type and config
  845. //
  846. GetPrivateProfileString(cszDeviceSection,
  847. cszDeviceType,
  848. szNull,
  849. lpRasEntry->szDeviceType,
  850. MAX_CHARS_IN_BUFFER(lpRasEntry->szDeviceType),
  851. szFileName);
  852. // Get Server Type settings
  853. //
  854. ImportServerInfo(lpRasEntry, szFileName);
  855. // Get IP address
  856. //
  857. ImportIPInfo(lpRasEntry, szFileName);
  858. // Import the script file
  859. //
  860. if ((dwRet = ImportScriptFile(lpRasEntry, szFileName)) != ERROR_SUCCESS)
  861. {
  862. //TraceMsg(TF_GENERAL, L"CONNECT:ImportScriptFile Failed with the error %d, %s,%s",dwRet,szFileName,lpRasEntry->szScript);
  863. }
  864. lpRasEntry->dwSize = sizeof(RASENTRY);
  865. // Load and Locate AutoRunSignUpWizard entry point
  866. //
  867. //hinetcfg = LoadLibrary(L"INETCFG.DLL");
  868. /*
  869. //AssertMsg(hinetcfg != NULL, L"Cannot find INETCFG.DLL");
  870. if (!hinetcfg)
  871. {
  872. dwRet = GetLastError();
  873. goto ImportConnectionExit;
  874. }
  875. fpSetAutoProxy = GetProcAddress(hinetcfg, cszSetAutoProxyConnectoid);
  876. if (fpSetAutoProxy)
  877. {
  878. ((SETAUTOPROXYCONNECTOID)fpSetAutoProxy) (FALSE);
  879. }
  880. fp = GetProcAddress(hinetcfg, AUTORUNSIGNUPWIZARDAPI);
  881. //AssertMsg(fp != NULL, L"Cannot find AutoRunSignupWizard entry point");
  882. if (!fp)
  883. {
  884. dwRet = GetLastError();
  885. goto ImportConnectionExit;
  886. }*/
  887. // 10/19/96 jmazner Normandy #8462 -- multiple modems
  888. dwRet = ConfigRasEntryDevice(lpRasEntry);
  889. switch( dwRet )
  890. {
  891. case ERROR_SUCCESS:
  892. break;
  893. case ERROR_CANCELLED:
  894. /*
  895. if( IDYES != MessageBox(GetActiveWindow(), GetSz(IDS_WANTTOEXIT), GetSz(IDS_TITLE),
  896. MB_APPLMODAL | MB_ICONQUESTION |
  897. MB_YESNO | MB_DEFBUTTON2) )
  898. {
  899. dwRet = ERROR_RETRY;
  900. }*/
  901. goto ImportConnectionExit;
  902. default:
  903. goto ImportConnectionExit;
  904. }
  905. if (lpRasEntry->szDeviceType[0] == TEXT('\0') &&
  906. lpRasEntry->szDeviceName[0] == TEXT('\0'))
  907. {
  908. lstrcpyn(lpRasEntry->szDeviceType, m_szDeviceType, RAS_MaxDeviceType);
  909. lstrcpyn(lpRasEntry->szDeviceName, m_szDeviceName, RAS_MaxDeviceName);
  910. }
  911. // See if this is a ISDN type device, and if so, then set the CFGFLAG_ISDN_OFFER
  912. if (lstrcmpi(g_szDeviceType, RASDT_Isdn) == 0)
  913. m_bIsISDNDevice = TRUE;
  914. ImportPhoneInfo(lpRasEntry, szFileName, m_bIsISDNDevice);
  915. //
  916. // ChrisK Olympus 4756 5/25/97
  917. // Do not display busy animation on Win95
  918. //
  919. dwOptions = INETCFG_INSTALLRNA |
  920. INETCFG_INSTALLTCP |
  921. INETCFG_OVERWRITEENTRY;
  922. dwRet = Rnaapi.InetConfigClientEx(
  923. NULL,
  924. NULL,
  925. pszEntryName,
  926. lpRasEntry,
  927. pszUserName,
  928. pszPassword,
  929. NULL,
  930. NULL,
  931. dwOptions,
  932. pfNeedsRestart,
  933. m_szConnectoidName,
  934. RAS_MaxEntryName+1);
  935. //if (fpSetAutoProxy)
  936. //{
  937. // ((SETAUTOPROXYCONNECTOID)fpSetAutoProxy) (TRUE);
  938. //}
  939. LclSetEntryScriptPatch(lpRasEntry->szScript, m_szConnectoidName);
  940. // now that we've made the connectoid in InetConfigClient (PFNAUTORUNSIGNUPWIZARD),
  941. // store its name in psheet's global so that we can delete it if user cancels
  942. //lstrcpyn( m_szConnectoidName, pszEntryName, lstrlen(pszEntryName) + 1);
  943. lstrcpyn( pszEntryName, m_szConnectoidName, lstrlen(pszEntryName) + 1);
  944. //TraceMsg(TF_GENERAL, "CONNECT:EntryName %s, User %s, Password (not shown), Number %s\n", pszEntryName,pszUserName,lpRasEntry->szLocalPhoneNumber);
  945. //AssertMsg(!fNeedsRestart, L"We have to reboot AGAIN!!");
  946. // Exit and cleanup
  947. //
  948. ImportConnectionExit:
  949. //if (hinetcfg)
  950. // FreeLibrary(hinetcfg);
  951. GlobalFree(lpRasEntry);
  952. return dwRet;
  953. }
  954. //+----------------------------------------------------------------------------
  955. //
  956. // Function GetDeviceSelectedByUser
  957. //
  958. // Synopsis Get the name of the RAS device that the user had already picked
  959. //
  960. // Arguements szKey - name of sub key
  961. // szBuf - pointer to buffer
  962. // dwSize - size of buffer
  963. //
  964. // Return TRUE - success
  965. //
  966. // History 10/24/96 ChrisK Created
  967. //-----------------------------------------------------------------------------
  968. BOOL CISPImport::GetDeviceSelectedByUser (LPWSTR szKey, LPWSTR szBuf, DWORD dwSize)
  969. {
  970. BOOL bRC = FALSE;
  971. HKEY hkey = NULL;
  972. DWORD dwType = 0;
  973. if (ERROR_SUCCESS == RegOpenKey(HKEY_LOCAL_MACHINE, ISIGNUP_KEY, &hkey))
  974. {
  975. if (ERROR_SUCCESS == RegQueryValueEx(hkey, szKey, 0,&dwType,
  976. (LPBYTE)szBuf, &dwSize))
  977. bRC = TRUE;
  978. }
  979. if (hkey)
  980. RegCloseKey(hkey);
  981. return bRC;
  982. }
  983. //+----------------------------------------------------------------------------
  984. // Function SetDeviceSelectedByUser
  985. //
  986. // Synopsis Write user's device selection to registry
  987. //
  988. // Arguments szKey - name of key
  989. // szBuf - data to write to key
  990. //
  991. // Returns TRUE - success
  992. //
  993. // History 10/24/96 ChrisK Created
  994. //-----------------------------------------------------------------------------
  995. BOOL CISPImport::SetDeviceSelectedByUser (LPWSTR szKey, LPWSTR szBuf)
  996. {
  997. BOOL bRC = FALSE;
  998. HKEY hkey = 0;
  999. if (ERROR_SUCCESS == RegOpenKey(HKEY_LOCAL_MACHINE,
  1000. ISIGNUP_KEY, &hkey))
  1001. {
  1002. if (ERROR_SUCCESS == RegSetValueEx(hkey, szKey, 0,REG_SZ,
  1003. (LPBYTE)szBuf, BYTES_REQUIRED_BY_SZ(szBuf)))
  1004. bRC = TRUE;
  1005. }
  1006. if (hkey)
  1007. RegCloseKey(hkey);
  1008. return bRC;
  1009. }
  1010. //+----------------------------------------------------------------------------
  1011. // Funciton DeleteUserDeviceSelection
  1012. //
  1013. // Synopsis Remove registry keys with device selection
  1014. //
  1015. // Arguments szKey - name of value to remove
  1016. //
  1017. // Returns TRUE - success
  1018. //
  1019. // History 10/24/96 ChrisK Created
  1020. //-----------------------------------------------------------------------------
  1021. BOOL CISPImport::DeleteUserDeviceSelection(LPWSTR szKey)
  1022. {
  1023. BOOL bRC = FALSE;
  1024. HKEY hkey = NULL;
  1025. if (ERROR_SUCCESS == RegOpenKey(HKEY_LOCAL_MACHINE, ISIGNUP_KEY, &hkey))
  1026. {
  1027. bRC = (ERROR_SUCCESS == RegDeleteValue(hkey, szKey));
  1028. RegCloseKey(hkey);
  1029. }
  1030. return bRC;
  1031. }
  1032. //+---------------------------------------------------------------------------
  1033. //
  1034. // Function: ConfigRasEntryDevice()
  1035. //
  1036. // Synopsis: Checks whether user has already specified a modem to use;
  1037. // If so, verifies that modem is valid.
  1038. // If not, or if modem is invalid, presents user a dialog
  1039. // to choose which modem to use (if only one modem is installed,
  1040. // it automaticaly selects that device and bypasses the dialog)
  1041. //
  1042. // Arguments: lpRasEntry - Pointer to the RasEntry whose szDeviceName and
  1043. // szDeviceType members you wish to verify/configure
  1044. //
  1045. // Returns: ERROR_CANCELLED - Had to bring up "Choose Modem" dialog, and
  1046. // and user hit its "Cancel" button
  1047. // Otherwise returns any error code encountered.
  1048. // ERROR_SUCCESS indicates success.
  1049. //
  1050. // History: 5/18/96 VetriV Created
  1051. // 3/7/98 DonSc Added the process-wide tracking of the previously
  1052. // selected device.
  1053. //
  1054. //----------------------------------------------------------------------------
  1055. DWORD CISPImport::ConfigRasEntryDevice( LPRASENTRY lpRasEntry )
  1056. {
  1057. DWORD dwRet = ERROR_SUCCESS;
  1058. #if 0
  1059. CEnumModem EnumModem;
  1060. GetDeviceSelectedByUser(DEVICENAMEKEY, g_szDeviceName, sizeof(g_szDeviceName));
  1061. GetDeviceSelectedByUser(DEVICETYPEKEY, g_szDeviceType, sizeof(g_szDeviceType));
  1062. ASSERT(lpRasEntry);
  1063. dwRet = EnumModem.GetError();
  1064. if (ERROR_SUCCESS != dwRet)
  1065. {
  1066. return dwRet;
  1067. }
  1068. // If there are no modems, we're horked
  1069. if (0 == EnumModem.GetNumDevices())
  1070. {
  1071. //TraceMsg(TF_GENERAL, L"ICWHELP: import.cpp: ConfigRasEntryDevice: ERROR: No modems installed!\n");
  1072. return ERROR_CANCELLED;
  1073. }
  1074. // Validate the device if possible
  1075. if ( lpRasEntry->szDeviceName[0] && lpRasEntry->szDeviceType[0] )
  1076. {
  1077. // Verify that there is a device with the given name and type
  1078. if (!EnumModem.VerifyDeviceNameAndType(lpRasEntry->szDeviceName,
  1079. lpRasEntry->szDeviceType))
  1080. {
  1081. // There was no device that matched both name and type,
  1082. // so reset the strings and bring up the choose modem UI.
  1083. lpRasEntry->szDeviceName[0] = L'\0';
  1084. lpRasEntry->szDeviceType[0] = L'\0';
  1085. }
  1086. }
  1087. else if ( lpRasEntry->szDeviceName[0] )
  1088. {
  1089. // Only the name was given. Try to find a matching type.
  1090. // If this fails, fall through to recovery case below.
  1091. LPWSTR szDeviceType =
  1092. EnumModem.GetDeviceTypeFromName(lpRasEntry->szDeviceName);
  1093. if (szDeviceType)
  1094. {
  1095. lstrcpy (lpRasEntry->szDeviceType, szDeviceType);
  1096. }
  1097. }
  1098. else if ( lpRasEntry->szDeviceType[0] )
  1099. {
  1100. // Only the type was given. Try to find a matching name.
  1101. // If this fails, fall through to recovery case below.
  1102. LPWSTR szDeviceName =
  1103. EnumModem.GetDeviceNameFromType(lpRasEntry->szDeviceType);
  1104. if (szDeviceName)
  1105. {
  1106. lstrcpy (lpRasEntry->szDeviceName, szDeviceName);
  1107. }
  1108. }
  1109. // If either name or type is missing, check whether the user has already made a choice.
  1110. // if not, bring up choose modem UI if there
  1111. // are multiple devices, else just get first device.
  1112. // Since we already verified that there was at least one device,
  1113. // we can assume that this will succeed.
  1114. if( !(lpRasEntry->szDeviceName[0]) ||
  1115. !(lpRasEntry->szDeviceType[0]) )
  1116. {
  1117. //TraceMsg(TF_GENERAL, L"ICWHELP: ConfigRasEntryDevice: no valid device passed in\n");
  1118. if( g_szDeviceName[0] )
  1119. {
  1120. // it looks like we have already stored the user's choice.
  1121. // store the DeviceName in lpRasEntry, then call GetDeviceTypeFromName
  1122. // to confirm that the deviceName we saved actually exists on the system
  1123. lstrcpy(lpRasEntry->szDeviceName, g_szDeviceName);
  1124. if( 0 == lstrcmp(EnumModem.GetDeviceTypeFromName(lpRasEntry->szDeviceName),
  1125. g_szDeviceType) )
  1126. {
  1127. lstrcpy(lpRasEntry->szDeviceType, g_szDeviceType);
  1128. return ERROR_SUCCESS;
  1129. }
  1130. }
  1131. if (1 == EnumModem.GetNumDevices())
  1132. {
  1133. // There is just one device installed, so copy the name
  1134. //TraceMsg(TF_GENERAL, L"ICWHELP: import.cpp: ConfigRasEntryDevice: only one modem installed, using it\n");
  1135. lstrcpy (lpRasEntry->szDeviceName, EnumModem.Next());
  1136. }
  1137. else
  1138. {
  1139. //TraceMsg(TF_GENERAL, L"ICWHELP: import.cpp: ConfigRasEntryDevice: multiple modems detected\n");
  1140. if (IsNT4SP3Lower())
  1141. {
  1142. lstrcpy (lpRasEntry->szDeviceName, EnumModem.Next() );
  1143. }
  1144. else
  1145. {
  1146. // structure to pass to dialog to fill out
  1147. CHOOSEMODEMDLGINFO ChooseModemDlgInfo;
  1148. // Display a dialog and allow the user to select modem
  1149. // TODO: is g_hWndMain the right thing to use for parent?
  1150. BOOL fRet=DialogBoxParam(GetModuleHandle(L"ICWHELP.DLL"), MAKEINTRESOURCE(IDD_CHOOSEMODEMNAME), GetActiveWindow(),
  1151. ChooseModemDlgProc, (LPARAM) &ChooseModemDlgInfo);
  1152. if (TRUE != fRet)
  1153. {
  1154. // user cancelled or an error occurred.
  1155. dwRet = ChooseModemDlgInfo.hr;
  1156. /*
  1157. dwRet = GetLastError(); //This will NEVER be ERROR_SUCCESS
  1158. //BUBGUG -- If the user hits OK -> then ChooseModemDlgInfo.hr == ERROR_SUCCESS,
  1159. BUT if OK was hit then the function returns true and this can never be hit!
  1160. if (ERROR_SUCCESS == dwRet)
  1161. {
  1162. // Error occurred, but the error code was not set.
  1163. dwRet = ERROR_INETCFG_UNKNOWN;
  1164. }*/
  1165. return dwRet;
  1166. }
  1167. // Copy the modem name string
  1168. lstrcpy (lpRasEntry->szDeviceName, ChooseModemDlgInfo.szModemName);
  1169. }
  1170. }
  1171. // Now get the type string for this modem
  1172. lstrcpy (lpRasEntry->szDeviceType, EnumModem.GetDeviceTypeFromName(lpRasEntry->szDeviceName));
  1173. }
  1174. lstrcpy(g_szDeviceName, lpRasEntry->szDeviceName);
  1175. lstrcpy(g_szDeviceType, lpRasEntry->szDeviceType);
  1176. // Save device name and type
  1177. lstrcpy( m_szDeviceName, lpRasEntry->szDeviceName);
  1178. lstrcpy( m_szDeviceType, lpRasEntry->szDeviceType);
  1179. // Save data in registry
  1180. SetDeviceSelectedByUser(DEVICENAMEKEY, g_szDeviceName);
  1181. SetDeviceSelectedByUser (DEVICETYPEKEY, g_szDeviceType);
  1182. #endif
  1183. return dwRet;
  1184. }