Microsoft Windows CE 3.0  


This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Handles created and used by the WinInet functions are called HINTERNETs. These HINTERNEThandles returned by the WinInet functions in Windows CE control only Internet functions. They are not native system handles. Therefore, only an Internet function works with its corresponding Internet handle. HINTERNEThandles cannot be used with functions such as ReadFileor CloseHandle. Similarly, native system handles cannot be used with the WinInet functions. For example, a handle returned by CreateFilecannot be passed to InternetReadFile.

HINTERNEThandles 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 InternetOpenfunction is the root node. Handles returned by the InternetConnectfunction occupy the next level. Handles returned by the FtpOpenFile, FtpFindFirstFile, and HttpOpenRequestfunctions are the leaf nodes.

The following illustration shows the hierarchy of the HINTERNEThandles. Each box represents a WinInet function that returns an HINTERNEThandle.

At the top level is InternetOpen, which creates the root HINTERNET. The next level contains InternetOpenUrland InternetConnect. The functions that use the HINTERNEThandle returned by InternetConnectmake up the last level.

All HINTERNEThandles can be closed by using InternetCloseHandle. Client applications must close all HINTERNEThandles derived from the HINTERNEThandle 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"),
InternetOpenUrl( hRootHandle,
TEXT(""), 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.

 Last updated on Friday, April 02, 2004

© 2004 Microsoft Corporation. All rights reserved.