به ترتیب از توابع InternetGetConnectedState API و InternetCheckConnection استفاده کنید