Internet Connection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to make a program that can connect the internet, I tried the API
function:
[DllImport("wininet.dll", SetLastError=true, CharSet=CharSet.Auto)]
static extern IntPtr InternetConnect(
IntPtr hInternet, string lpszServerName, int nServerPort,
string lpszUsername, string lpszPassword, int dwService,
int dwFlags, int dwContext);
The description of the function is here
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/internetconnect.asp
But when I use it thus:
InternetConnect(
IntPtr.Zero,"http://www.yahoo.com",
MyUserName,Password,2,
2, 0);
Nothing happens and I get the null returned.
Maybe it's becuase I don't use the correct flags in 6th and the 7th
arguments since I don't know there exact values I only guess.
Or Is there anything else wrong.
PS:I use a regular ADSL connection
Thanks for your help.
In addition, if there is some more simple function in the Net. FrameWork
please tell me what is it and how to use it.
Thanks again
 
Yes, there is an easier way.

Look up HTTPWebRequest
This will allow you to make a request against a web site and get the
response (which is usually a web page).

--- Nick
 
Back
Top