Click here to Skip to main content
15,885,683 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
I want to know my system is connected to a network or not and I am working in visual c++ 6.0. How could i detect a network through a visual c++ application ???? I also need the codes for same.
Posted

This link might be helpful:-

http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/ea29ed9e-9506-4fd5-9f69-b348a6e5ebdf[^]

Mark this as your answer if it helps you out or else response with query
 
Share this answer
 
Use InternetGetConnectedState() [^] to get the state. When configured and offline, you may connect using InternetAttemptConnect(0) [^] (this may show the dial-up dialog).

You may also use InternetCheckConnection(), but this uses pings which may fail if ICMP echo request (pings) are blocked somewhere on the route to the host URL.
 
Share this answer
 
Comments
chaiein 5-Apr-12 6:43am    
should we use any header file in vc9.0?
Even i need this solution.
Jochen Arndt 5-Apr-12 6:52am    
The above links mention the requirements including the wininet.h header file. If not included, the compiler will throw an error. A common place to include this header file is stdafx.h.
C++
#include "Wininet.h"
bool bstate= InternetGetConnectedState(&dwFlags,0);


This works where bstate shows 0 or 1 where 0 is no connection else 1 is with internet connection.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900