-
InternetConnect fails
In a program I am making I decided to use the wininet library. So I linked it and got everything set up. Then I tried to connect to google using InternetConnect. I know I saw something on MSDN that says if you use the user part blank it will return an error if you are using the HTTP protocol, which I am. Here is the parameters I passed to InternetConnect:
Code:
InternetConnect(NULL,"www.google.com",INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,0,0);
The two NULL parameters after INTERNET_DEFAULT_HTTP_PORT are the user and password. I did try plugging "guest" into those but still failed. By failing I don't mean not compiling I mean returning a NULL handle. Is there a certain thing I need to send as user or am I doing something wrong? Thanks.
-
Well saying which error(s) you've got rather than just "doesn't work" would help.
As would a bit of code around the single function call, which is no doubt the same as the example line on MSDN.
-
You have to call InternetOpen first and supply the returned handle to InternetConnect. WinINet sample here.
-
Yes, thanks anonytmouse that was the problem. I didn't supply any code because I had a feeling it was a simple problem like that. If it turned out to be more complex(which it wasn't) I would have supplied more information. Salem I don't see where I put "doesn't work" in my first post, oh yeah that's because I DIDN'T! I said it returned a NULL handle not an error.
-
So you did this?
Code:
InternetOpen(TEXT("www.google.com"), PRE_CONFIG_INTERNET_ACCESS, NULL, NULL, 0));
InternetConnect(NULL,"www.google.com",INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SER VICE_HTTP,0,0);
-
I did this:
Code:
HINTERNET IntOp=InternetOpen("NewBrowserTool",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,INTERNET_FLAG_ASYNC);
if(IntOp!=NULL)
{
HINTERNET hGoogle=InternetConnect(IntOp,"www.google.com",INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,NULL,NULL);
}