Oded
2009-09-30 10:38:01 UTC
Hi,
we are using wininet API for HTTP communication. all works well, but on
windows Vista for some reason we keep getting error 120007
(ERROR_INTERNET_NAME_NOT_RESOLVED ) when openinng HTTP request
(HttpOpenRequest call). we used a sample code provided by MS themselves, and
we get the same result (see below). Note that all is working ok on XP and
also on the windows 7 RC (and the users which is running the application are
all admin users).
any ideas?
the code we use is:
(argv[1] - the domain, argv[2] - the page)
#include <windows.h>
#include <WinINet.h>
#include <iostream>
using namespace std;
int main(int argc, char** 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, argv[1], INTERNET_DEFAULT_HTTP_PORT,
NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
if(!hConnect)
{
cout << "hconnect " << GetLastError() << endl;
return 0;
}
hReq = HttpOpenRequest(hConnect, "GET", argv[2], "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;
}
we are using wininet API for HTTP communication. all works well, but on
windows Vista for some reason we keep getting error 120007
(ERROR_INTERNET_NAME_NOT_RESOLVED ) when openinng HTTP request
(HttpOpenRequest call). we used a sample code provided by MS themselves, and
we get the same result (see below). Note that all is working ok on XP and
also on the windows 7 RC (and the users which is running the application are
all admin users).
any ideas?
the code we use is:
(argv[1] - the domain, argv[2] - the page)
#include <windows.h>
#include <WinINet.h>
#include <iostream>
using namespace std;
int main(int argc, char** 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, argv[1], INTERNET_DEFAULT_HTTP_PORT,
NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
if(!hConnect)
{
cout << "hconnect " << GetLastError() << endl;
return 0;
}
hReq = HttpOpenRequest(hConnect, "GET", argv[2], "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;
}