...

View Full Version : InternetOpenUrl parameters are confusing



pcweirdo
01-03-2004, 01:57 AM
gday,

i've got the below code, which is me trying to get a website. i'm working up to a http client, but for now i'm learning a little about the wininet API calls.

anyway, every time i compile i get an error from Visual C++ that there's too few parameters in InternetOpenUrlA. Any ideas on how to fix this?


#include <windows.h>
#include <wininet.h>


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
//MessageBox(GetDesktopWindow(), "w00t!", "1337", MB_OK | MB_ICONINFORMATION);
char* buf = "";
HINTERNET hOpen;
HINTERNET hFile;
LPDWORD ret;
hOpen = InternetOpen("pat", INTERNET_OPEN_TYPE_DIRECT, " ", 0);
hFile = InternetOpenUrl(hOpen, "www.microsoft.com", NULL, 0, INTERNET_FLAG_RELOAD, 0);
InternetReadFile(hFile, buf, 1000, ret);
InternetCloseHandle(hOpen);
InternetCloseHandle(hFile);
MessageBox(GetDesktopWindow(), buf, "www.microsoft.com", MB_OK | MB_ICONINFORMATION);
return 0;
}

thanks,
-pcweirdo.

shmoove
01-03-2004, 07:51 AM
From MSDN:


lpszUrl
Address of a string that contains the URL to begin reading. Only URLs beginning with ftp:, gopher:, http:, or https: are supported.

So maybe try passing "http://www.microsoft.com".

shmoove

pcweirdo
01-04-2004, 11:20 PM
apparently it's a problem with the number of arguments in InternetOpenUrlA. I've accquired some sample code from another site.

thanks,
-pcweirdo.

Mhtml
01-05-2004, 03:49 AM
HINTERNET InternetOpenUrl(
IN HINTERNET hInternetSession,
IN LPCSTR lpszUrl,
IN LPCSTR lpszHeaders,
IN DWORD dwHeadersLength,
IN DWORD dwFlags,
IN DWORD dwContext
);

I don't see how you have too few (or too many) arguments, that is the prototype definition from msdn ...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum