MicrosoftWin32InternetFunctionswqe.docx

上传人:jix****n11 文档编号:63483729 上传时间:2022-11-25 格式:DOCX 页数:92 大小:73.23KB
返回 下载 相关 举报
MicrosoftWin32InternetFunctionswqe.docx_第1页
第1页 / 共92页
MicrosoftWin32InternetFunctionswqe.docx_第2页
第2页 / 共92页
点击查看更多>>
资源描述

《MicrosoftWin32InternetFunctionswqe.docx》由会员分享,可在线阅读,更多相关《MicrosoftWin32InternetFunctionswqe.docx(92页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、Microsoft Win32 Internet Functions 91Microsoft Win32 Internet FunctionsPurpose and BackgroundThe Microsoft Win32 Internet functions provide Win32-based applications with easy access to common Internet protocols. These functions abstract the Internets Gopher, FTP ( protocol), and HTTP (hypertext tran

2、sfer protocol) protocols into a high-level application programming interface (API) that is familiar to independent software vendors (ISVs) and software developers, and that provides a fast and straightforward path to making applications Internet-aware. NoteInitially, the Win32 Internet functions wil

3、l be shipped as redistributables independent of operating systems through the Microsoft Developer Network (MSDN), CompuServe, and the Internet. ISVs can redistribute Wininet.dll with their applications, following the model of Win32s. In the future, the functions described in this documentation will

4、be folded into all Microsoft operating systems. The Win32 Internet functions are exported from Wininet.dll. The Win32 Internet functions facilitate access to the Internet by: Eliminating the need to embed knowledge of TCP/IP and Windows Sockets. By converting the Internet protocols into task-oriente

5、d functions, application developers do not need to write Windows Sockets code or be familiar with the TCP/IP protocol. Eliminating the need to embed knowledge of Internet protocols. While the concepts supported by the Internet protocols, such as HTTP, are simple, the actual implementation of these p

6、rotocols can be complex. For example, return ASCII text listings, but parsing these listings requires specific knowledge of the format returned by each . By encapsulating this functionality within the Internet functions, directory parsing is solved once for all applications using the . This provides

7、 consistent behavior across applications. Providing a constant set of functions in an environment of rapidly changing and evolving protocols. Keeping pace with the changes in Internet protocols is a challenge when writing applications. With the set of functions designed to remain constant, applicati

8、on developers no longer need to update their applications every time the underlying protocol changes. Now, only Wininet.dll needs to be changed. In addition, advanced protocols, such as HTTP version 1.1, can also be implemented without changing applications. Following Win32 function standards. The W

9、in32 Internet functions are similar to the traditional Win32 functions in the way they treat elements such as buffer management and error returns. Application developers familiar with the Win32 function set will find that the Win32 Internet functions return information in a familiar format. Furtherm

10、ore, application developers will find it easy to use the returned information in other Win32 functions. Providing full access to Internet protocols. Occasionally, applications need to access extended features of the Internet protocols. The Win32 Internet functions help provide this access. Enabling

11、high-performance, multithreaded Internet applications. The Win32 Internet functions are fully reentrant and multithread safe. Multithreaded applications can make simultaneous calls into the functions from different threads without adverse effects. The Internet functions themselves complete any neces

12、sary synchronization. Having persistent caching support built in. The Win32 Internet functions provide persistent caching for all protocols, so the application developer can concentrate on obtaining the data and not worrying about managing the cache. For more information about how Win32 Internet fun

13、ctions use the cache functions to get proper Web behavior, see Persistent URL Cache Functions. The Win32 Internet functions are intended to make Internet client applications easier to write; they are not intended to facilitate writing Internet servers. This is because servers must be able to control

14、 how the protocol is accessed and how I/O is performed in order to achieve the high performance necessary for high-traffic servers. In addition, the Win32 Internet functions are not intended to solve the general issue of access to mail and news servers. Overview of the Win32 Internet FunctionsThe fo

15、llowing table summarizes the Win32 Internet functions. Each function indicates any functions that it is dependent on. A dependent function can be called only after the related higher-level function is called. This is because the higher-level function returns a handle and sets up a state at the proto

16、col level that is a prerequisite to the successful execution of the dependent function or functions. General Win32 Internet Functions InternetOpen Initializes the applications use of the Win32 Internet functions and creates the root HINTERNET handle InternetConnect Opens an FTP, Gopher, or HTTP sess

17、ion with a server. This function requires a handle created by InternetOpen . InternetCloseHandle Closes any designated handle created by a Win32 Internet function and any handles derived from that handle. InternetQueryOption Queries the setting of an Internet option. InternetSetOption Sets an Intern

18、et option. InternetSetStatusCallback Sets a callback function that is called with status information. Assigns a callback function to the designated HINTERNET handle and all of the handles derived from it. InternetStatusCallback This is a placeholder for the application-defined status callback. Inter

19、netConfirmZoneCrossing Checks for changes between secure and non-secure URLs. InternetTimeFromSystemTime Formats a date and time according to the specified RFC format (as specified in the HTTP version 1.0 specification). InternetTimeToSystemTime Takes an HTTP time/date string and converts it to a SY

20、STEMTIME structure. InternetAttemptConnect Allows an application to attempt to connect to the Internet before issuing any requests. InternetReadFile Dowloads data from the Internet. This function requires a handle created by InternetOpenUrl, , GopherOpenFile, or HttpOpenRequest. InternetSet Sets the

21、 position for the next read in a file. This function requires a handle created by InternetOpenUrl (on an HTTP URL only) or a handle created by HttpOpenRequest using the GET method. InternetFindNextFile Continues or search. This function requires a handle created by or GopherFindFirstFile. InternetQu

22、eryDataAvailable Queries the amount of data available. This function requires a handle created by , GopherOpenFile, or HttpOpenRequest. InternetGetLastResponseInfo Retrieves the text of the servers response to the . This function requires a handle created by InternetConnect. InternetWriteFile Writes

23、 data to an open file. This function requires a handle created by . InternetCrackUrl Parses a URL string into components. InternetCreateUrl Creates a URL string from components. InternetCanonicalizeUrl Converts a URL to a canonical form. InternetCombineUrl Combines base and relative URLs. InternetOp

24、enUrl Begins retrieving a complete FTP, Gopher, or HTTP URL. This function requires a handle created by InternetOpen. Starts or in the current directory. This function requires a handle created by InternetConnect. Retrieves an entire the server. This function requires a handle created by InternetCon

25、nect. Writes an entire the server. This function requires a handle created by InternetConnect. Deletes a the server. This function requires a handle created by InternetConnect. Renames a the server. This function requires a handle created by InternetConnect. Initiates access to a the server for eith

26、er reading or writing. This function requires a handle created by InternetConnect. Creates a new directory on the server. This function requires a handle created by InternetConnect. Deletes a directory on the server. This function requires a handle created by InternetConnect. Changes the clients cur

27、rent directory on the server. This function requires a handle created by InternetConnect. Returns the clients current directory on the server. This function requires a handle created by InternetConnect. Gopher Functions GopherFindFirstFile Starts enumerating a Gopher directory listing. This function

28、 requires a handle created by InternetConnect. GopherOpenFile Starts retrieving a Gopher object. This function requires a handle created by InternetConnect. GopherCreateLocator Forms a Gopher locator for use in other Gopher function calls. GopherGetAttribute Retrieves attribute information on the Go

29、pher object. This function requires a handle created by InternetConnect. HTTP (World Wide Web) Functions HttpOpenRequest Opens an HTTP request handle. This function requires a handle created by InternetConnect. HttpAddRequestHeaders Adds HTTP request headers to the HTTP request handle. This function

30、 requires a handle created by HttpOpenRequest. HttpSendRequest Sends the specified request to the HTTP server. This function requires a handle created by HttpOpenRequest. HttpQueryInfo Queries information about an HTTP request. This function requires a handle created by HttpOpenRequest. InternetErro

31、rDlg Displays predefined dialog boxes for common Internet error conditions. Requires the handle used in the call to the function HttpSendRequest. Cookie Functions InternetGetCookie Returns cookies for the specified URL and all its parent URLs. InternetSetCookie Sets a cookie on the specified URL. Ca

32、che Functions CommitUrlCacheEntry Caches data in the specified the cache storage and associates it with the given URL. CreateUrlCacheEntry Allocates the requested cache storage and creates a local for saving the cache entry corresponding to the source name. GetUrlCacheEntryInfo Retrieves information

33、 about a cache entry. ReadUrlCacheEntryStream Reads the cached data from a stream that has been opened using RetrieveUrlCacheEntryStream. RetrieveUrlCacheEntryFile Retrieves a cache entry from the cache in the form of a file. RetrieveUrlCacheEntryStream Provides the most efficient and implementation

34、-independent way of accessing the cache data. SetUrlCacheEntryInfo Sets the specified members of the INTERNET_CACHE_ENTRY_INFO structure. UnlockUrlCacheEntryFile Unlocks the cache entry that was locked while the retrieved for use from the cache. UnlockUrlCacheEntryStream Closes the stream that has b

35、een retrieved using RetrieveUrlCacheEntryStream. DeleteUrlCacheEntry Removes the with the source name from the cache, if the . FindCloseUrlCache Closes the specified enumeration handle. FindFirstUrlCacheEntry Begins the enumeration of the cache. FindNextUrlCacheEntry Retrieves the next entry in the

36、cache. HandlesThe handles that are created and used by the Win32 Internet functions are opaque handle types called HINTERNETS. These handles returned by the Win32 Internet function APIs are not interchangeable with the base Win32 handles, so they cannot be used with Win32 APIs such as Read CloseHand

37、le. Similarly, base Win32 handles cannot be used with the Win32 Internet function APIs. For example, a handle returned by Create be passed to InternetReadFile. If a callback function was registered for a handle, all operations on that handle can generate status indications, provided that the context

38、 value that was supplied when the handle was created was not zero. Providing a zero context value is a method to force an operation to complete synchronously, even though INTERNET_FLAG_ASYNC was specified in InternetOpen. Status indications are mainly intended to give the application feedback as to

39、the progress of an operation, and are mainly concerned with network operations, such as resolving a host name, connecting to a server, and receiving data. Three special-purpose status indications can be made for a handle: INTERNET_STATUS_REQUEST_COMPLETE is indicated when an asynchronous operation c

40、ompletes. INTERNET_STATUS_HANDLE_CREATED is indicated when the handle is initially created. INTERNET_STATUS_HANDLE_CLOSING is the last status indication that will be made for a handle. The application must check the INTERNET_ASYNC_RESULTS structure to determine whether the operation succeeded or fai

41、led after receiving an INTERNET_STATUS_REQUEST_COMPLETE indication. The InternetCloseHandle function closes handles of type HINTERNET and all handles that descended from it in the Handle Hierarchy function. Note that handle values are recycled quickly; therefore, if a handle is closed and a new hand

42、le is generated immediately, there is a good chance that the new handle will have the same value as the handle just closed. Handle HierarchyHandles returned from Win32 Internet functions are maintained in a tree hierarchy. The handle returned by the InternetOpen function is the root node. Handles re

43、turned from the InternetConnect function occupy the next level. Currently, handles that are returned by open or find functions, such as HttpOpenRequest and , are the leaf nodes. This structure can be used by InternetCloseHandle to close a single handle or an entire subtree. Multithreaded AccessThe W

44、in32 Internet functions are reentrant in the sense that there can be multiple calls to an individual function from different threads. The functions complete any necessary synchronization. However, multiple simultaneous calls using the same Internet connection can lead to unpredictable results. For e

45、xample, if an application has used to begin downloading a an , and two threads simultaneously make calls to InternetReadFile, there is no guarantee which call will be completed first, or which thread will receive first. Applications that use multiple threads for the same Internet connection are resp

46、onsible for synchronization between threads to ensure a predictable return of information. Error HandlingThe Win32 Internet functions return error information in the same way as Win32 functions. Return values tell whether the function is successful or not. For example, some Internet functions return

47、 a BOOL value that is TRUE if the function succeeded or FALSE if it failed, and others return a handle of type HINTERNET. A NULL handle indicates that the function failed, and any other value indicates that it succeeded. If a function fails, the application can call the Win32 Internet function GetLa

48、stError to retrieve the specific error code for the failure. In addition, the Gopher protocols let servers return additional error information. For these protocols, applications can use the InternetGetLastResponseInfo function to retrieve error text. Both GetLastError and InternetGetLastResponseInfo operate on a per-thread basis. If two threads call Internet functions at the same time, error information will be returned for each of the individual threads so that there is no conflict between the th

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 技术方案

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁