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.

281 lines
7.5 KiB

  1. //****************************************************************************
  2. //
  3. // Module: INETCFG.DLL
  4. // File: iclient.c
  5. // Content: This file contains all the functions that handle importing
  6. // client information.
  7. // History:
  8. // Sat 10-Mar-1996 23:50:40 -by- Mark MacLin [mmaclin]
  9. // 96/03/13 markdu Assimilated with inetcfg.dll.
  10. // 96/03/20 markdu Combined export.h and iclient.h into inetcfg.h
  11. // 96/04/18 markdu NASH BUG 18443
  12. //
  13. // Copyright (c) Microsoft Corporation 1991-1996
  14. //
  15. //****************************************************************************
  16. //#include "wizard.h"
  17. //#include "inetcfg.h"
  18. #include "obcomglb.h"
  19. #define REGSTR_PATH_INTERNET_CLIENT L"Software\\Microsoft\\Internet ClientX"
  20. #pragma data_seg(".rdata")
  21. // registry constants
  22. static const WCHAR cszRegPathInternetClient[] = REGSTR_PATH_INTERNET_CLIENT;
  23. static const WCHAR cszRegValEMailName[] = L"EMail_Name";
  24. static const WCHAR cszRegValEMailAddress[] = L"EMail_Address";
  25. static const WCHAR cszRegValPOPLogonRequired[] = L"POP_Logon_Required";
  26. static const WCHAR cszRegValPOPLogonName[] = L"POP_Logon_Name";
  27. static const WCHAR cszRegValPOPLogonPassword[] = L"POP_Logon_Password";
  28. static const WCHAR cszRegValPOPServer[] = L"POP_Server";
  29. static const WCHAR cszRegValSMTPServer[] = L"SMTP_Server";
  30. static const WCHAR cszRegValNNTPLogonRequired[] = L"NNTP_Logon_Required";
  31. static const WCHAR cszRegValNNTPLogonName[] = L"NNTP_Logon_Name";
  32. static const WCHAR cszRegValNNTPLogonPassword[] = L"NNTP_Logon_Password";
  33. static const WCHAR cszRegValNNTPServer[] = L"NNTP_Server";
  34. static const WCHAR cszNull[] = L"";
  35. static const WCHAR cszYes[] = L"yes";
  36. static const WCHAR cszNo[] = L"no";
  37. #pragma data_seg()
  38. //*******************************************************************
  39. //
  40. // FUNCTION: InetGetClientInfo
  41. //
  42. // PURPOSE: This function will get the internet client params
  43. // from the registry
  44. //
  45. // PARAMETERS: lpClientInfo - on return, this structure will contain
  46. // the internet client params as set in the registry.
  47. // lpszProfileName - Name of client info profile to
  48. // retrieve. If this is NULL, the default profile is used.
  49. //
  50. // RETURNS: HRESULT code, ERROR_SUCCESS if no errors occurred
  51. //
  52. //*******************************************************************
  53. extern HRESULT WINAPI InetGetClientInfo(
  54. LPCWSTR lpszProfileName,
  55. LPINETCLIENTINFO lpClientInfo)
  56. {
  57. HKEY hKey;
  58. DWORD dwRet;
  59. DWORD dwSize;
  60. DWORD dwType;
  61. DWORD dwVal;
  62. if (sizeof(INETCLIENTINFO) > lpClientInfo->dwSize)
  63. {
  64. return ERROR_INSUFFICIENT_BUFFER;
  65. }
  66. dwRet = RegOpenKey(HKEY_CURRENT_USER, cszRegPathInternetClient, &hKey);
  67. if (ERROR_SUCCESS != dwRet)
  68. {
  69. return dwRet;
  70. }
  71. lpClientInfo->dwFlags = 0;
  72. dwSize = sizeof(dwVal);
  73. dwType = REG_DWORD;
  74. RegQueryValueEx(
  75. hKey,
  76. cszRegValPOPLogonRequired,
  77. 0L,
  78. &dwType,
  79. (LPBYTE)&dwVal,
  80. &dwSize);
  81. if (dwVal)
  82. {
  83. lpClientInfo->dwFlags |= INETC_LOGONMAIL;
  84. }
  85. dwSize = sizeof(dwVal);
  86. dwType = REG_DWORD;
  87. RegQueryValueEx(
  88. hKey,
  89. cszRegValNNTPLogonRequired,
  90. 0L,
  91. &dwType,
  92. (LPBYTE)&dwVal,
  93. &dwSize);
  94. if (dwVal)
  95. {
  96. lpClientInfo->dwFlags |= INETC_LOGONNEWS;
  97. }
  98. dwSize = sizeof(lpClientInfo->szEMailName);
  99. dwType = REG_SZ;
  100. RegQueryValueEx(
  101. hKey,
  102. cszRegValEMailName,
  103. 0L,
  104. &dwType,
  105. (LPBYTE)lpClientInfo->szEMailName,
  106. &dwSize);
  107. dwSize = sizeof(lpClientInfo->szEMailAddress);
  108. dwType = REG_SZ;
  109. RegQueryValueEx(
  110. hKey,
  111. cszRegValEMailAddress,
  112. 0L,
  113. &dwType,
  114. (LPBYTE)lpClientInfo->szEMailAddress,
  115. &dwSize);
  116. dwSize = sizeof(lpClientInfo->szPOPServer);
  117. dwType = REG_SZ;
  118. RegQueryValueEx(
  119. hKey,
  120. cszRegValPOPServer,
  121. 0L,
  122. &dwType,
  123. (LPBYTE)lpClientInfo->szPOPServer,
  124. &dwSize);
  125. dwSize = sizeof(lpClientInfo->szSMTPServer);
  126. dwType = REG_SZ;
  127. RegQueryValueEx(
  128. hKey,
  129. cszRegValSMTPServer,
  130. 0L,
  131. &dwType,
  132. (LPBYTE)lpClientInfo->szSMTPServer,
  133. &dwSize);
  134. dwSize = sizeof(lpClientInfo->szNNTPServer);
  135. dwType = REG_SZ;
  136. RegQueryValueEx(
  137. hKey,
  138. cszRegValNNTPServer,
  139. 0L,
  140. &dwType,
  141. (LPBYTE)lpClientInfo->szNNTPServer,
  142. &dwSize);
  143. RegCloseKey(hKey);
  144. return ERROR_SUCCESS;
  145. }
  146. //*******************************************************************
  147. //
  148. // FUNCTION: InetSetClientInfo
  149. //
  150. // PURPOSE: This function will set the internet client params
  151. //
  152. // PARAMETERS: lpClientInfo - pointer to struct with info to set
  153. // in the registry.
  154. // lpszProfileName - Name of client info profile to
  155. // modify. If this is NULL, the default profile is used.
  156. //
  157. // RETURNS: HRESULT code, ERROR_SUCCESS if no errors occurred
  158. //
  159. //*******************************************************************
  160. HRESULT WINAPI InetSetClientInfo(
  161. LPCWSTR lpszProfileName,
  162. LPINETCLIENTINFO lpClientInfo)
  163. {
  164. HKEY hKey;
  165. DWORD dwRet;
  166. DWORD dwSize;
  167. DWORD dwType;
  168. DWORD dwVal;
  169. if (sizeof(INETCLIENTINFO) > lpClientInfo->dwSize)
  170. {
  171. return ERROR_INSUFFICIENT_BUFFER;
  172. }
  173. dwRet = RegCreateKey(HKEY_CURRENT_USER, cszRegPathInternetClient, &hKey);
  174. if (ERROR_SUCCESS != dwRet)
  175. {
  176. return dwRet;
  177. }
  178. dwVal = lpClientInfo->dwFlags & INETC_LOGONMAIL ? 1 : 0;
  179. dwSize = sizeof(dwVal);
  180. dwType = REG_DWORD;
  181. RegSetValueEx(
  182. hKey,
  183. cszRegValPOPLogonRequired,
  184. 0L,
  185. dwType,
  186. (LPBYTE)&dwVal,
  187. dwSize);
  188. dwVal = lpClientInfo->dwFlags & INETC_LOGONNEWS ? 1 : 0;
  189. dwSize = sizeof(dwVal);
  190. dwType = REG_DWORD;
  191. RegSetValueEx(
  192. hKey,
  193. cszRegValNNTPLogonRequired,
  194. 0L,
  195. dwType,
  196. (LPBYTE)&dwVal,
  197. dwSize);
  198. dwSize = sizeof(lpClientInfo->szEMailName);
  199. dwType = REG_SZ;
  200. RegSetValueEx(
  201. hKey,
  202. cszRegValEMailName,
  203. 0L,
  204. dwType,
  205. (LPBYTE)lpClientInfo->szEMailName,
  206. dwSize);
  207. dwSize = sizeof(lpClientInfo->szEMailAddress);
  208. dwType = REG_SZ;
  209. RegSetValueEx(
  210. hKey,
  211. cszRegValEMailAddress,
  212. 0L,
  213. dwType,
  214. (LPBYTE)lpClientInfo->szEMailAddress,
  215. dwSize);
  216. dwSize = sizeof(lpClientInfo->szPOPServer);
  217. dwType = REG_SZ;
  218. RegSetValueEx(
  219. hKey,
  220. cszRegValPOPServer,
  221. 0L,
  222. dwType,
  223. (LPBYTE)lpClientInfo->szPOPServer,
  224. dwSize);
  225. dwSize = sizeof(lpClientInfo->szSMTPServer);
  226. dwType = REG_SZ;
  227. RegSetValueEx(
  228. hKey,
  229. cszRegValSMTPServer,
  230. 0L,
  231. dwType,
  232. (LPBYTE)lpClientInfo->szSMTPServer,
  233. dwSize);
  234. dwSize = sizeof(lpClientInfo->szNNTPServer);
  235. dwType = REG_SZ;
  236. RegSetValueEx(
  237. hKey,
  238. cszRegValNNTPServer,
  239. 0L,
  240. dwType,
  241. (LPBYTE)lpClientInfo->szNNTPServer,
  242. dwSize);
  243. RegCloseKey(hKey);
  244. return dwRet;
  245. }