1. The method defined in [DllImport ( "wininet.dll")] private extern static bool InternetGetConnectedState (out int connectionDescription, int reservedValue); 2. Description Parameter Method: connectionDescription: connection Description reservedValue: retention Return Value: true: On Line false : OFF line 3. Call method a. You must reference system.Runtime.InteropServices in your code, otherwise there will be compilation error b. Define a variable INT i = 0; c. Call Bool State = InternetGetConnectedState (Out i, 0); the 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;}}}}