Click here to Skip to main content
12,624,887 members (37,712 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C++
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 15-Feb-12 21:31pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
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.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

#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.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 5 Apr 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100