You receive an "ERROR_FILE_NOT_FOUND" error message when you try to use the WinHttpGetIEProxyConfigForCurrentUser function

Article translations Article translations
Article ID: 873200 - View products that this article applies to.
Expand all | Collapse all

On This Page

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:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
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.

MORE INFORMATION

Steps to reproduce the problem

  1. Log on to a computer where Internet Explorer has never been used.
  2. Start Microsoft Visual Studio .NET.
  3. On the File menu, point to New, and then click Project.
  4. Under Project Types, click Visual C++ Projects.
  5. Under Templates, click Win32 Project.
  6. In the Name box, type Test, and then click OK.
  7. On the Welcome to the Win32 Application Wizard page, click Application Settings.
  8. Under Application type, click Console application, and then click Finish.

    The Test.cpp file is created.
  9. Replace the existing code in the Test.cpp file with the following code:
    #include "stdafx.h"
    
    #include <Windows.h>
    #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 << "WinHttpGetIEProxyConfigForCurrentUser failed with the following error number: " << Err << endl;
    		switch (Err)
    		{
    			case ERROR_FILE_NOT_FOUND:
    				cout << "The error is ERROR_FILE_NOT_FOUND" << endl;
    				break;
    			case ERROR_WINHTTP_INTERNAL_ERROR:
    				cout << "ERROR_WINHTTP_INTERNAL_ERROR" << endl;
    				break;
    			case ERROR_NOT_ENOUGH_MEMORY:
    				cout << "ERROR_NOT_ENOUGH_MEMORY" << endl;
    				break;
    			default:
    				cout << "Look up error in header file." << endl; 
    
    		}//end switch
    	}//end if
    	else
    	{
    		//no error so check the proxy settings and free any strings
    		cout << "Auto Detect is: " << MyProxyConfig.fAutoDetect << endl;
    		if(NULL != MyProxyConfig.lpszAutoConfigUrl)
    		{
    			wcout << "AutoConfigURL is: " << MyProxyConfig.lpszAutoConfigUrl << endl;
    			GlobalFree(MyProxyConfig.lpszAutoConfigUrl);
    		}
    		if(NULL != MyProxyConfig.lpszProxy)
    		{
    			wcout << "AutoConfigURL is: " << MyProxyConfig.lpszProxy << endl;
    			GlobalFree(MyProxyConfig.lpszProxy);
    		}
    		if(NULL != MyProxyConfig.lpszProxyBypass)
    		{
    			wcout << "AutoConfigURL is: " << MyProxyConfig.lpszProxyBypass << endl;
    			GlobalFree(MyProxyConfig.lpszProxyBypass);
    		}
    
    	}//end else
    	cout << "finished!";
    }//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/
  10. On the Project menu, click Test Properties.
  11. In the left pane, double-click Linker.
  12. Under Linker, click Input.
  13. In the right pane, type winhttp.lib in the Additional Dependencies field, and then click OK.
  14. On the Build menu, click Build Solution.
  15. Press CTRL+F5 to run the program without the debugger.

    You receive the error message that is mentioned in the "Symptoms" section.

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web site:
http://msdn2.microsoft.com/en-us/library/aa384096.aspx

Properties

Article ID: 873200 - Last Review: January 11, 2007 - Revision: 1.2
APPLIES TO
  • Microsoft Windows HTTP Services 5.1
Keywords: 
kberrmsg kbprb kbhttp kbsettings kbconfig kbtshoot KB873200

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com