Export (0) Print
Expand All

WinHttpGetDefaultProxyConfiguration function

The WinHttpGetDefaultProxyConfiguration function retrieves the default WinHTTP proxy configuration from the registry.

Syntax


BOOL WINAPI WinHttpGetDefaultProxyConfiguration(
  _Inout_  WINHTTP_PROXY_INFO *pProxyInfo
);

Parameters

pProxyInfo [in, out]

A pointer to a variable of type WINHTTP_PROXY_INFO that receives the default proxy configuration.

Return value

Returns TRUE if successful or FALSE otherwise. To retrieve a specific error message, call GetLastError. Error codes returned include the following.

Error CodeDescription
ERROR_WINHTTP_INTERNAL_ERROR

An internal error has occurred.

ERROR_NOT_ENOUGH_MEMORY

Not enough memory was available to complete the requested operation. (Windows error code)

 

Remarks

WinHttpGetDefaultProxyConfiguration retrieves the proxy configuration set by WinHttpSetDefaultProxyConfiguration or ProxyCfg.exe.

The default proxy configuration can be overridden for a WinHTTP session by calling WinHttpSetOption and specifying the WINHTTP_OPTION_PROXY flag. WinHttpGetDefaultProxyConfiguration does not retrieve the configuration for the current session. It retrieves the configuration specified in the registry.

If the registry contains a list of proxy servers, the dwAccessType member of pProxyInfo is set to WINHTTP_ACCESS_TYPE_NAMED_PROXY. Otherwise, it is set to WINHTTP_ACCESS_TYPE_NO_PROXY.

WinHttpGetDefaultProxyConfiguration allocates memory for the string members of pProxyInfo. To free this memory, call GlobalFree.

Even when WinHTTP is used in asynchronous mode (that is, when WINHTTP_FLAG_ASYNC has been set in WinHttpOpen), this function operates synchronously. The return value indicates success or failure. To get extended error information, call GetLastError.

Note  For Windows XP and Windows 2000, see the Run-Time Requirements section of the WinHTTP Start Page.

Examples

The following code example shows how to retrieve the default proxy configuration from the registry.


    WINHTTP_PROXY_INFO proxyInfo;

    // Retrieve the default proxy configuration.
    WinHttpGetDefaultProxyConfiguration( &proxyInfo );

    // Display the proxy servers and free memory 
    // allocated to this string.
    if (proxyInfo.lpszProxy != NULL)
    {
        printf("Proxy server list: %S\n", proxyInfo.lpszProxy);
        GlobalFree( proxyInfo.lpszProxy );
    }

    // Display the bypass list and free memory 
    // allocated to this string.
    if (proxyInfo.lpszProxyBypass != NULL)
    {
        printf("Proxy bypass list: %S\n", proxyInfo.lpszProxyBypass);
        GlobalFree( proxyInfo.lpszProxyBypass );
    }


Requirements

Minimum supported client

Windows XP, Windows 2000 Professional with SP3 [desktop apps only]

Minimum supported server

Windows Server 2003, Windows 2000 Server with SP3 [desktop apps only]

Redistributable

WinHTTP 5.0 and Internet Explorer 5.01 or later on Windows XP and Windows 2000.

Header

Winhttp.h

Library

Winhttp.lib

DLL

Winhttp.dll

See also

ProxyCfg.exe, a Proxy Configuration Tool
WinHttpSetDefaultProxyConfiguration
WinHTTP Versions

 

 

Community Additions

ADD
Show:
© 2014 Microsoft