Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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

↑ Back to the top


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.

↑ Back to the top


Resolution

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

↑ Back to the top


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:
  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.

↑ Back to the top


References

For more information, visit the following Microsoft Developer Network (MSDN) Web site:

↑ Back to the top


Keywords: kberrmsg, kbprb, kbhttp, kbsettings, kbconfig, kbwiprotr, kbwiproauthor, kbtshoot, kb

↑ Back to the top

Article Info
Article ID : 873200
Revision : 2
Created on : 8/1/2019
Published on : 8/1/2019
Exists online : False
Views : 359