Microsoft KB Archive/873200

= You receive an &quot;ERROR_FILE_NOT_FOUND&quot; error message when you try to use the WinHttpGetIEProxyConfigForCurrentUser function =

Article ID: 873200

Article Last Modified on 1/11/2007

-

APPLIES TO


 * Microsoft Windows HTTP Services 5.1

-



SYMPTOMS
If your computer has never run Microsoft Internet Explorer and you use the WinHttpGetIEProxyConfigForCurrentUser function in any program, you receive the following error message:

ERROR_FILE_NOT_FOUND



CAUSE
The WinHttpGetIEProxyConfigForCurrentUser function uses the following registry subkey:

This registry subkey is created the first time that Internet Explorer runs. If your computer has not run Internet Explorer, this registry subkey does not exist. When you call the WinHttpGetIEProxyConfigForCurrentUser function in a program, the function searches for this registry entry and cannot find it, and you receive the error message.



RESOLUTION
To resolve this problem, start Internet Explorer, and then use the WinHttpGetIEProxyConfigForCurrentUser function in any program.



Steps to reproduce the problem
 Log on to a computer where Internet Explorer has never been used. Start Microsoft Visual Studio .NET. On the File menu, point to New, and then click Project. Under Project Types, click Visual C++ Projects. Under Templates, click Win32 Project. In the Name box, type Test, and then click OK.</li> On the Welcome to the Win32 Application Wizard page, click Application Settings.</li> Under Application type, click Console application, and then click Finish.

The Test.cpp file is created.</li>  Replace the existing code in the Test.cpp file with the following code:
 * 1) include &quot;stdafx.h&quot;


 * 1) include <Windows.h>
 * 2) include <Winhttp.h>

using namespace std;

void main {   WINHTTP_CURRENT_USER_IE_PROXY_CONFIG MyProxyConfig; if(!WinHttpGetIEProxyConfigForCurrentUser(&MyProxyConfig)) {       //check the error DWORD Err = GetLastError; cout << &quot;WinHttpGetIEProxyConfigForCurrentUser failed with the following error number: &quot; << Err << endl; switch (Err) {           case ERROR_FILE_NOT_FOUND: cout << &quot;The error is ERROR_FILE_NOT_FOUND&quot; << endl; break; case ERROR_WINHTTP_INTERNAL_ERROR: cout << &quot;ERROR_WINHTTP_INTERNAL_ERROR&quot; << endl; break; case ERROR_NOT_ENOUGH_MEMORY: cout << &quot;ERROR_NOT_ENOUGH_MEMORY&quot; << endl; break; default: cout << &quot;Look up error in header file.&quot; << endl;

}//end switch }//end if   else {       //no error so check the proxy settings and free any strings cout << &quot;Auto Detect is: &quot; << MyProxyConfig.fAutoDetect << endl; if(NULL != MyProxyConfig.lpszAutoConfigUrl) {           wcout << &quot;AutoConfigURL is: &quot; << MyProxyConfig.lpszAutoConfigUrl << endl; GlobalFree(MyProxyConfig.lpszAutoConfigUrl); }       if(NULL != MyProxyConfig.lpszProxy) {           wcout << &quot;AutoConfigURL is: &quot; << MyProxyConfig.lpszProxy << endl; GlobalFree(MyProxyConfig.lpszProxy); }       if(NULL != MyProxyConfig.lpszProxyBypass) {           wcout << &quot;AutoConfigURL is: &quot; << MyProxyConfig.lpszProxyBypass << endl; GlobalFree(MyProxyConfig.lpszProxyBypass); }

}//end else cout << &quot;finished!&quot;; }//end main Note The Winhttp.h file and the Winhttp.lib file are included in the Microsoft Platform software development kit (SDK). To download the Platform SDK, visit the following Microsoft Web site:

http://www.microsoft.com/msdownload/platformsdk/sdkupdate/

</li> On the Project menu, click Test Properties.</li> In the left pane, double-click Linker.</li> Under Linker, click Input.</li> In the right pane, type winhttp.lib in the Additional Dependencies field, and then click OK.</li> On the Build menu, click Build Solution.</li> Press CTRL+F5 to run the program without the debugger.

You receive the error message that is mentioned in the &quot;Symptoms&quot; section.</li></ol>

<div class="references_section">