Internet Connection

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
 
N

Nick Malik

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top