Dela via

WinHttpDetectAutoProxyConfigUrl function (winhttp.h)

The WinHttpDetectAutoProxyConfigUrl function finds the URL for the Proxy Auto-Configuration (PAC) file. This function reports the URL of the PAC file, but it does not download the file.


WINHTTPAPI BOOL WinHttpDetectAutoProxyConfigUrl(
  [in]  DWORD  dwAutoDetectFlags,
  [out] LPWSTR *ppwstrAutoConfigUrl


[in] dwAutoDetectFlags

A data type that specifies what protocols to use to locate the PAC file. If both the DHCP and DNS auto detect flags are set, DHCP is used first; if no PAC URL is discovered using DHCP, then DNS is used.

Value Meaning
Use DHCP to locate the proxy auto-configuration file.
Use DNS to attempt to locate the proxy auto-configuration file at a well-known location on the domain of the local computer.

[out] ppwstrAutoConfigUrl

A data type that returns a pointer to a null-terminated Unicode string that contains the configuration URL that receives the proxy data. You must free the string pointed to by ppwszAutoConfigUrl using the GlobalFree function.

Return value

Returns TRUE if successful, or FALSE otherwise. For extended error information, call GetLastError. Among the error codes returned are the following.

Error Code Description
Returned if WinHTTP was unable to discover the URL of the Proxy Auto-Configuration (PAC) file.
An internal error has occurred.
Not enough memory was available to complete the requested operation. (Windows error code)


WinHTTP implements the Web Proxy Auto-Discovery (WPAD) protocol, often referred to as autoproxy. For more information about well-known locations, see the Discovery Process section of the WPAD protocol document.

Note that because the WinHttpDetectAutoProxyConfigUrl function takes time to complete its operation, it should not be called from a UI thread.


Requirement Value
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]
Target Platform Windows
Header winhttp.h
Library Winhttp.lib
DLL Winhttp.dll

See also

WinHTTP Versions