Click here to Skip to main content
Rate this: bad
good
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 20:31pm
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 at 5-Apr-12 6:43am
   
should we use any header file in vc9.0?
Even i need this solution.
Jochen Arndt at 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 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 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
0 Sergey Alexandrovich Kryukov 392
1 OriginalGriff 370
2 CPallini 190
3 Abdul Samad KP 145
4 George Jonsson 119
0 OriginalGriff 6,329
1 Sergey Alexandrovich Kryukov 5,700
2 CPallini 4,940
3 George Jonsson 3,469
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 5 Apr 2012
Copyright © CodeProject, 1999-2014
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