c sample sharing for determining network connection status
- 2020-06-15 10:06:12
- OfStack
public partial class Form1 : Form {
[DllImport("wininet.dll")]
private extern static bool getInterState(out int conn, int val);
public Form1() {
InitializeComponent();
getNet();
}
// Determines whether the current connection is in Internet network
private void getNet()
{
int Out;
if (getInterState(out Out, 0) == true)
{
label1.Text = " The network is connected! ";
}else{
label1.Text = " The network failed to connect! ";
}
}
}