X
1. Method definition
[DllImport ("Wininet.dll")]
private extern static bool InternetGetConnectedState (out int connectiondescription, int reservedvalue);
2. Method description
Parameters:
Connectiondescription: Connection Description
Reservedvalue: Reserved values
return value:
True:on Line
False:off Line
3. Calling methods
A. You must refer to System.Runtime.InteropServices in your code, otherwise there will be a compilation error
B. Define a variable int I = 0;
C. invoke bool state = InternetGetConnectedState (out i,0);
Complete code:
using System.Runtime.InteropServices;
namespace internet
{
public class Class1
{
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState( out int connectionDescription, int reservedValue ) ;
public Class1(){}
private bool IsConnected()
{
int I=0;
bool state = InternetGetConnectedState(out I,0);
return state;
}
}
}
With this stone of diligence, fill the gap of ability!