다음을 통해 공유


About HINTERNET Handles (Windows CE 5.0)

Send Feedback

Handles created and used by the Windows Internet Services (WinInet) functions are called HINTERNETs. These HINTERNET handles are not native system handles. They are only returned by the WinInet functions. As such, you cannot use HINTERNET handles with functions such as ReadFile or CloseHandle, nor can you use native system handles, returned by functions such as CreateFile, with the WinInet functions.

HINTERNET handles are maintained in a tree hierarchy in which a higher-level function must be called before a dependent function is called. The handle returned by the InternetOpen function is the root node. Handles returned by the InternetConnect function occupy the next level. Handles returned by the FtpOpenFile, FtpFindFirstFile, and HttpOpenRequest functions are the leaf nodes.

The following illustration shows the hierarchy of the HINTERNET handles. Each box represents a WinInet function that returns an HINTERNET handle.

Aa451879.inethand(en-us,MSDN.10).gif

At the top level is InternetOpen, which creates the root HINTERNET. The next level contains InternetOpenUrl and InternetConnect. The functions that use the HINTERNET handle returned by InternetConnect make up the last level.

All HINTERNET handles can be closed by InternetCloseHandle. Client applications must close all HINTERNET handles derived from the HINTERNET handle to be closed before calling InternetCloseHandle.

The following code example shows the handle hierarchy for the WinInet functions.

HINTERNET hRootHandle, hOpenUrlHandle;
hRootHandle = InternetOpen(
                           TEXT("Example"), 
                           INTERNET_OPEN_TYPE_DIRECT, 
                           NULL, 
                           NULL, 
                           0);
hOpenUrlHandle = InternetOpenUrl(
                              hRootHandle, 
                              TEXT("http://www.server.com/default.htm"),
                              NULL,
                              0,
                              INTERNET_FLAG_RAW_DATA,
                              0);

// Close the handle created by InternetOpenUrl, so that the
// InternetOpen handle can be closed.
InternetCloseHandle(hOpenUrlHandle); 

// Close the handle created by InternetOpen.
InternetCloseHandle(hRootHandle);

**Note   **Handle values are recycled quickly. Therefore, if a handle is closed and a new handle is generated immediately, the new handle can have the same value as the handle just closed.

See Also

WinInet Application Development

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.