Many organizations install proxy servers to filter IP packets to control access to internal systems from other users on the Internet, and perhaps to control the type of protocols or servers that users in the organization can access. In this situation users actually communicate with the proxy server, and the proxy server connects to the requested server on the user's behalf. Thus, when writing code, you need to instruct the Internet functions to use the proxy server. This is done when calling InternetOpen. For example, the following code fragment specifies that a proxy server with the name "SPPROXY" should be used. hHttpOpen = InternetOpen(_T("Example Agent"), INTERNET_OPEN_TYPE_PROXY, _T("SPPROXY"), // proxy server NULL, // no bypass addresses 0); // no flags The proxy is specified by passing (see Table 8.1):
Note that bypass addresses are not supported in Windows CE. In Windows NT/98/2000, bypass addresses can be used to specify servers that should be accessed directly and not through the proxy server. In Windows CE proxy server information can be stored in the registry, and InternetOpen can read the registry keys directly. This is done by specifying the INTERNET_OPEN_TYPE_PRECONFIG dwAccessType constant: hHttpOpen = InternetOpen(_T("Example Agent"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, // default proxy NULL, // no bypass addresses 0); // no flags The registry key HKEY_CURRENT_USER\Comm\Wininet\ProxyServer stores the proxy information. The value specifies the name of the server and port number in the form "protocol=scheme://server:port". Windows CE only supports accessing servers through a single proxy server. For example, the proxy server "spproxy" would be specified by: Key: HKEY_CURRENT_USER\Comm\Wininet\ProxyServer Value: HTTP=http://spproxy:80 If INTERNET_OPEN_TYPE_PRECONFIG is specified but the correct registry information cannot be located, InternetOpen reverts to INTERNET_OPEN_TYPE_DIRECT, that is, it attempts to connect to the server directly.
|