Hi all mister,
Which is THE BEST WAY IN THE WORLD AROUND for:
1. detect Network
2. detect Internet Connection is working...
which is the best way in the world and good practice recommended by MVPs
Microsoft ?
Thanks in advanced..
code below...but which is the best code ???
NetworkInterfac e.GetIsNetworkA vailable()
private static int ERROR_SUCCESS = 0;
public static bool IsInternetConne cted() {
long dwConnectionFla gs = 0;
if (!InternetGetCo nnectedState(dw ConnectionFlags , 0))
return false;
if(InternetAtte mptConnect(0) != ERROR_SUCCESS)
return false;
return true;
}
[DllImport("wini net.dll", SetLastError=tr ue)]
public static extern int InternetAttempt Connect(uint res);
[DllImport("wini net.dll", SetLastError=tr ue)]
public static extern bool InternetGetConn ectedState(long flags,long
reserved);
Correct translation below.
[DllImport("wini net.dll", SetLastError=tr ue)] public static extern bool
InternetGetConn ectedState(out int flags,int reserved);
I found code in C#,
HttpWebRequest req;
HttpWebResponse resp;
try
{
req = (HttpWebRequest )WebRequest.Cre ate("http://www.google.com" );
resp = (HttpWebRespons e)req.GetRespon se();
if(resp.StatusC ode.ToString(). Equals("OK"))
{
Console.WriteLi ne("its connected.");
}
else
{
Console.WriteLi ne("its not connected.");
}
}
catch(Exception exc)
{
Console.WriteLi ne("its not connected.");
}
--------------------------------------------------------------------------------
http://www.alhambra-eidos.es/web2005/index.html
--
http://www.alhambra-eidos.es/web2005/index.html www.kiquenet.com/churrosoft http://www.setbb.com/putainformatica...opic.php?p=843 www.trabajobasura.com/solusoft