Hi,
What is the best way to check internet connection in windows application?
Hi,
What is the best way to check internet connection in windows application?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Amit MohantyRank #112 · 20K reputationPosted Dec 8, 2022, 7:53 AM EST
Hey try this
[DllImport("wininet.dll")] private extern static bool InternetGetConnectedState(out int description, int reservedValue); public static bool IsInternetAvailable() => InternetGetConnectedState(out int description, 0); private void Form_Load(object sender, EventArgs e) { if (IsInternetAvailable()) MessageBox.Show("Internet Available"); else MessageBox.Show("Internet Not Available"); }