Microsoft KB Archive/839873

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

Article ID: 839873

Article Last Modified on 1/25/2007

-

APPLIES TO


 * Microsoft Internet Explorer (Programming) 6 (SP1)

-



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 &quot;Symptoms&quot; 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, &quot;www.microsoft.com&quot;, INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);



Upgrade Microsoft Internet Explorer 6.0
 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

 Double-click the Q832894.exe file. The Microsoft Internet Explorer Update dialog box appears. 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 , type  :\ in the Location box, and then click OK. The Win32 Application Wizard -   dialog box appears.

Notes
 * 1) *  is a placeholder for the project name that you give to the project.
 * 2) *  is a placeholder for the hard disk of your computer.
 * 3) *  is a placeholder for the folder where you want to create your project.
 * 4) Click Finish.

Add code to the project
  Replace the existing code with the following code: // SimpleGet.cpp : Defines the entry point for the console application. //

using namespace std; int _tmain(int argc, _TCHAR* argv[]) {   HINTERNET hOpen, hConnect, hReq; hOpen = InternetOpen(&quot;SimpleGet&quot;, INTERNET_OPEN_TYPE_PRECONFIG, NULL, 0, 0); if(!hOpen) {       cout << &quot;hopen &quot; << GetLastError << endl; return 0; }   // try the following in InternetConnect to see the problem. hConnect = InternetConnect(hOpen, &quot;www.microsoft.com/learning/&quot;, INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); if(!hConnect) {       cout << &quot;hconnect &quot; << GetLastError << endl; return 0; }   hReq = HttpOpenRequest(hConnect, &quot;GET&quot;, &quot;&quot;, &quot;HTTP/1.1&quot;, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE, 0); if(!hReq) {       cout << &quot;hreq &quot; << GetLastError << endl; return 0; }   if(HttpSendRequest(hReq, NULL, 0, NULL, 0)) {       DWORD dwSize = 0; char Data[1024] = &quot;\0&quot;; DWORD dwCode, dwCodeSize; dwCodeSize = sizeof(DWORD); if(!HttpQueryInfo(hReq, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwCode, &dwCodeSize, NULL)) {           cout << &quot;queryinfo &quot; << GetLastError << endl; return 0; }       else {           cout << &quot;Status Code: &quot; << 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 << &quot;SendRequest error &quot; << GetLastError << endl; }   return 0; }   In Solution Explorer, under Header Files, double-click stdafx.h, and then add the following lines:
 * 1) include &quot;stdafx.h&quot;
 * 1) include <windows.h>

In Solution Explorer, right-click  , and then click Properties. The  Property Pages dialog box appears.</li> In the left pane, click Configuration Properties, click Linker, and then click Input.</li> In the right pane, click the Additional Dependencies field, type WinINet.lib, and then click OK.</li></ol>
 * 1) include <WinINet.h> </li>

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 &quot;Symptoms&quot; section.

<div class="references_section">