You may receive a WinINet 12007 error message when you call the SendRequest API after you apply the MS04-004 security update

Article translations Article translations
Article ID: 839873
Expand all | Collapse all

On This Page

Symptoms

On a computer that is running Microsoft Internet Explorer 6.0 with the security update MS04-004, when you try to call the InternetConnect method and then the SendRequest API of the WinINet library by passing the server name or the IP address followed by the virtual directory name, you may receive the following error message:

SendRequest error 12007
Note This error message corresponds to the following error message:

ERROR_INTERNET_NAME_NOT_RESOLVED
This error message translates to the following:

The server name could not be resolved

Cause

If you try to pass a server name with the virtually directory name to the InternetConnect method, you will notice the error message that is mentioned in the "Symptoms" section. The newer build of the WinINet library adheres strictly to the way that the Microsoft Developer Network (MSDN) documents the use of this API. WinINet does not support passing this kind of parameter to the InternetConnect method.

The MSDN documentation for the InternetConnect method describes the second parameter of the InternetConnect method as the following:
lpszServerName
[in] Pointer to a null-terminated string that specifies the host name of an Internet server. Alternately, the string can contain the IP number of the site, in ASCII dotted-decimal format (for example, 11.0.1.45).
Therefore, the InternetConnect method does not accept anything else other than the server name. If you also pass the virtual directory after the server name, your call to the InternetConnect method fails.

Resolution

To resolve this problem, do not pass anything other than the server name in the InternetConnect method. However, you can pass the IP address instead of the server name. For example, set the value of the lpszServerName parameter to 11.0.1.45. Therefore, the InternetConnect method only accepts the server name or the IP address. Alternatively, you can supply the path of the virtual directory followed by the file that you want to render in the HttpOpenRequest API after you call the InternetConnect method. For example, /mydir/myfile.html.

To resolve this problem, you can pass the IP or the server name in the InternetConnect method. For example, you can use the InteretConnect method as follows:
hConnect = InternetConnect(hOpen, "www.microsoft.com", INTERNET_DEFAULT_HTTP_PORT, 
NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);

More information

Steps to reproduce the behavior

Upgrade Microsoft Internet Explorer 6.0

  1. Download and then save the cumulative security update for Internet Explorer 6.0 Service Pack 1 (KB832894). The following file is available for download from the Microsoft Download Center:
    http://www.microsoft.com/downloads/details.aspx?FamilyId=70530968-B59A-47C0-90D3-0C884910BC97
  2. Double-click the Q832894.exe file. The Microsoft Internet Explorer Update dialog box appears.
  3. Click Yes to upgrade Internet Explorer 6.0.

Create a project

  1. Start Microsoft Visual Studio .NET.
  2. On the File menu, point to New, and then click Project. The New Project dialog box appears.
  3. Under Project Types, expand Visual C++ Projects, and then click Win32.
  4. Under Templates, click Win32 Console Project.
  5. In the Name box, type Name, type Drive:\FolderName in the Location box, and then click OK. The Win32 Application Wizard - Name dialog box appears.

    Notes
    • Name is a placeholder for the project name that you give to the project.
    • Drive is a placeholder for the hard disk of your computer.
    • FolderName is a placeholder for the folder where you want to create your project.
  6. Click Finish.

Add code to the project

  1. Replace the existing code with the following code:
    // SimpleGet.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    using namespace std;
    int _tmain(int argc, _TCHAR* argv[])
    {
    	HINTERNET hOpen, hConnect, hReq;
    	hOpen = InternetOpen("SimpleGet", INTERNET_OPEN_TYPE_PRECONFIG, NULL, 0, 0);
    	if(!hOpen)
    	{
    		cout << "hopen " << GetLastError() << endl;
    		return 0;
    	}
    	// try the following in InternetConnect to see the problem. 
    		hConnect = InternetConnect(hOpen, "www.microsoft.com/learning/", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
    	if(!hConnect)
    	{
    		cout << "hconnect " << GetLastError() << endl;
    		return 0;
    	}
    	hReq = HttpOpenRequest(hConnect, "GET", "", "HTTP/1.1", NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0);
    	if(!hReq)
    	{
    		cout << "hreq " << GetLastError() << endl;
    		return 0;
    	}
    	if(HttpSendRequest(hReq, NULL, 0, NULL, 0))
    	{
    		DWORD dwSize = 0;
    		char Data[1024] = "\0";
    		DWORD dwCode, dwCodeSize;
    		dwCodeSize = sizeof(DWORD);
    		if(!HttpQueryInfo(hReq, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwCode, &dwCodeSize, NULL))
    		{
    			cout << "queryinfo " << GetLastError() << endl;
    			return 0;
    		}
    		else
    		{
    			cout << "Status Code: " << dwCode << endl;
    		}
    		do
    		{
    			InternetReadFile(hReq, (LPVOID)Data, 1023, &dwSize);
    			if(0!=dwSize)
    			{
    				Data[dwSize]='\0';
    				cout << Data;
    			}
    			ZeroMemory(Data, 1024);
    		}while (dwSize !=0);
    	}
    	else
    	{
    		cout << "SendRequest error " << GetLastError() << endl;
    	}
    	return 0;
    }
  2. In Solution Explorer, under Header Files, double-click stdafx.h, and then add the following lines:
    #include <windows.h>
    #include <WinINet.h>
  3. In Solution Explorer, right-click Name, and then click Properties. The Name Property Pages dialog box appears.
  4. In the left pane, click Configuration Properties, click Linker, and then click Input.
  5. In the right pane, click the Additional Dependencies field, type WinINet.lib, and then click OK.

Build and then debug the project

  1. On the Build menu, click Build Solution.
  2. On the Debug menu, click Start Without Debugging to run the project without a debugger. You may notice the problem that is mentioned in the "Symptoms" section.

References

For additional information, visit the following Microsoft Web sites:
Microsoft Security Bulletin MS04-004
http://www.microsoft.com/technet/security/bulletin/MS04-004.mspx

InternetConnect
http://msdn2.microsoft.com/en-us/library/aa384363.aspx

Error Messages
http://msdn2.microsoft.com/en-us/library/aa385465.aspx

Properties

Article ID: 839873 - Last Review: June 20, 2014 - Revision: 2.0
Keywords: 
kbtshoot kbwebbrowser kbpatch kbapi kbinetdev kbprb KB839873
Retired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.

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