Click here to Skip to main content
13,354,885 members (78,723 online)
Rate this:
Please Sign up or sign in to vote.
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 15-Feb-12 21:31pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This link might be helpful:-[^]

Mark this as your answer if it helps you out or else response with query
Rate this: bad
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.
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
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.

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 |
Web02 | 2.8.180111.1 | Last Updated 5 Apr 2012
Copyright © CodeProject, 1999-2018
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