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.

232 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name :
  4. inetapi.h
  5. Abstract:
  6. wininet.dll wrapper class declaration.
  7. Author:
  8. Michael Cheuk (mcheuk)
  9. Project:
  10. Link Checker
  11. Revision History:
  12. --*/
  13. #ifndef _INETAPI_H_
  14. #define _INETAPI_H_
  15. #include <windows.h>
  16. #include <wininet.h>
  17. //------------------------------------------------------------------
  18. // wininet.dll entry points definitons
  19. typedef
  20. INTERNETAPI
  21. HINTERNET
  22. (WINAPI *
  23. pfnInternetOpenA)(
  24. IN LPCSTR lpszAgent,
  25. IN DWORD dwAccessType,
  26. IN LPCSTR lpszProxy OPTIONAL,
  27. IN LPCSTR lpszProxyBypass OPTIONAL,
  28. IN DWORD dwFlags
  29. );
  30. typedef
  31. INTERNETAPI
  32. INTERNET_STATUS_CALLBACK
  33. (WINAPI *
  34. pfnInternetSetStatusCallback)(
  35. IN HINTERNET hInternet,
  36. IN INTERNET_STATUS_CALLBACK lpfnInternetCallback
  37. );
  38. typedef
  39. INTERNETAPI
  40. HINTERNET
  41. (WINAPI *
  42. pfnInternetConnectA)(
  43. IN HINTERNET hInternet,
  44. IN LPCSTR lpszServerName,
  45. IN INTERNET_PORT nServerPort,
  46. IN LPCSTR lpszUserName OPTIONAL,
  47. IN LPCSTR lpszPassword OPTIONAL,
  48. IN DWORD dwService,
  49. IN DWORD dwFlags,
  50. IN DWORD dwContext
  51. );
  52. typedef
  53. INTERNETAPI
  54. HINTERNET
  55. (WINAPI *
  56. pfnHttpOpenRequestA)(
  57. IN HINTERNET hConnect,
  58. IN LPCSTR lpszVerb,
  59. IN LPCSTR lpszObjectName,
  60. IN LPCSTR lpszVersion,
  61. IN LPCSTR lpszReferrer OPTIONAL,
  62. IN LPCSTR FAR * lplpszAcceptTypes OPTIONAL,
  63. IN DWORD dwFlags,
  64. IN DWORD dwContext
  65. );
  66. typedef
  67. INTERNETAPI
  68. BOOL
  69. (WINAPI *
  70. pfnHttpAddRequestHeadersA)(
  71. IN HINTERNET hRequest,
  72. IN LPCSTR lpszHeaders,
  73. IN DWORD dwHeadersLength,
  74. IN DWORD dwModifiers
  75. );
  76. typedef
  77. INTERNETAPI
  78. BOOL
  79. (WINAPI *
  80. pfnHttpSendRequestA)(
  81. IN HINTERNET hRequest,
  82. IN LPCSTR lpszHeaders OPTIONAL,
  83. IN DWORD dwHeadersLength,
  84. IN LPVOID lpOptional OPTIONAL,
  85. IN DWORD dwOptionalLength
  86. );
  87. typedef
  88. INTERNETAPI
  89. BOOL
  90. (WINAPI *
  91. pfnHttpQueryInfoA)(
  92. IN HINTERNET hRequest,
  93. IN DWORD dwInfoLevel,
  94. IN OUT LPVOID lpBuffer OPTIONAL,
  95. IN OUT LPDWORD lpdwBufferLength,
  96. IN OUT LPDWORD lpdwIndex OPTIONAL
  97. );
  98. typedef
  99. INTERNETAPI
  100. BOOL
  101. (WINAPI *
  102. pfnInternetCloseHandle)(
  103. IN HINTERNET hInternet
  104. );
  105. typedef
  106. INTERNETAPI
  107. BOOL
  108. (WINAPI *
  109. pfnInternetReadFile)(
  110. IN HINTERNET hFile,
  111. IN LPVOID lpBuffer,
  112. IN DWORD dwNumberOfBytesToRead,
  113. OUT LPDWORD lpdwNumberOfBytesRead
  114. );
  115. typedef
  116. INTERNETAPI
  117. BOOL
  118. (WINAPI *
  119. pfnInternetCrackUrlA)(
  120. IN LPCSTR lpszUrl,
  121. IN DWORD dwUrlLength,
  122. IN DWORD dwFlags,
  123. IN OUT LPURL_COMPONENTS lpUrlComponents
  124. );
  125. typedef
  126. INTERNETAPI
  127. BOOL
  128. (WINAPI *
  129. pfnInternetCombineUrlA)(
  130. IN LPCSTR lpszBaseUrl,
  131. IN LPCSTR lpszRelativeUrl,
  132. OUT LPSTR lpszBuffer,
  133. IN OUT LPDWORD lpdwBufferLength,
  134. IN DWORD dwFlags
  135. );
  136. typedef
  137. INTERNETAPI
  138. HINTERNET
  139. (WINAPI *
  140. pfnInternetOpenUrlA)(
  141. IN HINTERNET hInternet,
  142. IN LPCSTR lpszUrl,
  143. IN LPCSTR lpszHeaders OPTIONAL,
  144. IN DWORD dwHeadersLength,
  145. IN DWORD dwFlags,
  146. IN DWORD dwContext
  147. );
  148. #define LOAD_ENTRY( hMod, Name ) \
  149. (##Name = (pfn##Name) GetProcAddress( (hMod), #Name ))
  150. //------------------------------------------------------------------
  151. // wininet.dll wrapper class
  152. class CWininet
  153. {
  154. // Public funtions
  155. public:
  156. // Constructor
  157. ~CWininet();
  158. // Destructor
  159. CWininet();
  160. // Load wininet.dll
  161. BOOL Load();
  162. // Is wininet.dll loaded in memory?
  163. static BOOL IsLoaded()
  164. {
  165. return (sm_hWininet != NULL);
  166. }
  167. // Get the wininet.dll static HMODULE
  168. static HMODULE GetWininetModule()
  169. {
  170. return sm_hWininet;
  171. }
  172. // Static wininet.dll API
  173. static pfnInternetOpenA InternetOpenA;
  174. static pfnInternetSetStatusCallback InternetSetStatusCallback;
  175. static pfnInternetConnectA InternetConnectA;
  176. static pfnHttpOpenRequestA HttpOpenRequestA;
  177. static pfnHttpAddRequestHeadersA HttpAddRequestHeadersA;
  178. static pfnHttpSendRequestA HttpSendRequestA;
  179. static pfnHttpQueryInfoA HttpQueryInfoA;
  180. static pfnInternetCloseHandle InternetCloseHandle;
  181. static pfnInternetReadFile InternetReadFile;
  182. static pfnInternetCrackUrlA InternetCrackUrlA;
  183. static pfnInternetCombineUrlA InternetCombineUrlA;
  184. static pfnInternetOpenUrlA InternetOpenUrlA;
  185. // Protected members
  186. protected:
  187. // Static wininet.dll HMODULE
  188. static HMODULE sm_hWininet;
  189. // Static instance count
  190. static int sm_iInstanceCount;
  191. }; // class CWininet
  192. #endif // _INETAPI_H_