[DllImport("wininet")]
private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);
private void btnOK_Click(object sender, EventArgs e)
{
//判斷是否聯網
int i = 0;
if (InternetGetConnectedState(out i, 0))
{
//聯網
MessageBox.Show("Thylx提醒您:你的計算機已連接到網絡上!");
}
else
{
//斷網
MessageBox.Show("Thylx提醒您:本地連接已斷開!");
}
}