Hello all
How I can detect whether my comp connected to internet or not (using C #)
thank you
Is it connected ?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
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 attend5days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Dec 20, 2009, 7:03 AM EST
Effective way of check it is using WIN API function GetConnectedState() as Ping might not work in some situation ..
[DllImport("WININET", CharSet=CharSet.Auto)] public static extern bool InternetGetConnectedState( ref InternetConnectionState lpdwFlags, int dwReserved ); after defining function just use it like normal function it will return True if Computer is connected else it will return False .Sam HobbsRank #107 · 20.5K reputationPosted Dec 20, 2009, 6:11 AM EST