SoFunction
Updated on 2025-03-06

C# Example sharing of network connection status


public partial class Form1 : Form {

[DllImport("")]

private extern static bool getInterState(out int conn, int val);

public Form1()  {
InitializeComponent(); 
getNet();
}

//Discern whether to connect to the Internet network
private void getNet()
{
int Out;
if (getInterState(out Out, 0) == true)
{
= "The network is connected!";
}else{
= "The network was not connected successfully!";
}
}
}