Click here to Skip to main content
15,882,114 members
Articles / Desktop Programming / MFC
Article

Showing Dial-up Connection Status Window

Rate me:
Please Sign up or sign in to vote.
4.13/5 (13 votes)
4 Dec 20011 min read 103.4K   3.3K   24   13
How to invoke Dial-up Connection status window programatically by Sundar & Naresh

Sample Image - Connectionstatus.jpg

Introduction

After dialing thru modem and connecting to Internet, we check the status of the connection by invoking the connection status window. This article describes how to invoke the connection status window programatically.In Windows 95,98 and NT it's very simple to invoke the same. Whereas in Windows XP and Windows 2000 we have write our own code to do the same.

Implementation

In Windows NT, we can show this window by means of control panel file Rascpl.cpl. The method is as follows :

WinExec("rundll32.exe shell32.dll,Control_RunDLL Rascpl.cpl,,5",1);

In Windows 9x, say for example the profile which we use to connect to Internet thru dial-up networking is 'Netlink '. Then after the connection is established the connection status window's title will be "Connected to Netlink". So make use of the FindWindow function to invoke the status window. The method is as follows :

if(FindWindow(NULL,"Connected to Netlink"))
{
    FindWindow(NULL,"Connected to Netlink")->ShowWindow(1);
}

In Windows XP and Windows 2000, this is not the case, so we have to write our own code get the connection status. For this we need to use the API RasGetConnectionStatistics and RAS_STATS structure. But the problem with this API and structure are, though they are present in the rasapi32.lib they are not declared in the ras.h header file. So, we must use the LoadLibray method and GetProcAddress function to use the library and the function. And the RAS_STATS structure must be defined as follows :

typedef struct _RAS_STATS 
{ 
DWORD dwSize;
DWORD dwBytesXmited; 
DWORD dwBytesRcved;
DWORD dwFramesXmited; 
DWORD dwFramesRcved; 
DWORD dwCrcErr; 
DWORD dwTimeoutErr; 
DWORD dwAlignmentErr; 
DWORD dwHardwareOverrunErr; 
DWORD dwFramingErr; 
DWORD dwBufferOverrunErr; 
DWORD dwCompressionRatioIn; 
DWORD dwCompressionRatioOut; 
DWORD dwBps; 
DWORD dwConnectDuration; 
} RAS_STATS, *PRAS_STATS;

Conclusion

The Source file and the demo file include here to show the connection status are strictly for Windows XP and Windows 2000. So the Pseudocode for showing the connection status window for the appropriate OS is as follows :

If (OS == IsWin9x())
{ 
  if(FindWindow(NULL,"Connected to Netlink"))
  {
    FindWindow(NULL,"Connected to Netlink")->ShowWindow(1);
  }
}
else If (OS == IsWinNT())
{ 
  WinExec("rundll32.exe shell32.dll,Control_RunDLL Rascpl.cpl,,5",1); 
}
if(OS == IsWinXP() || OS == IsWin2k())
{
  WinExec("Connectionstatus.exe",1);
    //Connectionstatus.exe is attached with the demo file included here.
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
Sundar is having 6 years of experience in VC++. and .NET for 2+ year. Has developed the Internet Dialer for Asia's No.1 leading ISP. Involved in developing Video Surveillance components for worlds leading Security Surveillance Software Company. Worked and working on various domains such as Internet Networking, Video Codecs, CCTV Surveillance Software, Video Portals, Windows Mobile, PDAs etc. Also working on various projects which involves RAS, TCP/IP, FTP, COM, XML, .NET, Remoting, Embedded programming.

Comments and Discussions

 
GeneralExtract/read connection status from window with GUI automation Pin
daluu17-Oct-07 12:56
daluu17-Oct-07 12:56 
QuestionHow to simply query for RAS connection speed? Pin
daluu16-Oct-07 15:59
daluu16-Oct-07 15:59 
GeneralRAS and "Which Port" Pin
Emily J.27-Mar-06 20:11
Emily J.27-Mar-06 20:11 
GeneralIncorrect Members Values in RAS_STATS Pin
jt_roxas4-Feb-06 7:15
jt_roxas4-Feb-06 7:15 
QuestionCan't understand why to use this form? Pin
NeutronMass5-Feb-05 11:40
NeutronMass5-Feb-05 11:40 
AnswerRe: Can't understand why to use this form? Pin
ThatsAlok1-Jun-05 23:39
ThatsAlok1-Jun-05 23:39 
General[Message Deleted] Pin
Ramadan DERVISHI19-Nov-03 3:15
sussRamadan DERVISHI19-Nov-03 3:15 
QuestionCould you tall me why show this error? Pin
no_body6925-Jun-03 0:30
no_body6925-Jun-03 0:30 
AnswerRe: Could you tall me why show this error? Pin
ThatsAlok9-Jan-05 17:56
ThatsAlok9-Jan-05 17:56 
GeneralRe: Could you tall me why show this error? Pin
Tieter7-Feb-06 9:03
Tieter7-Feb-06 9:03 
GeneralRe: Could you tall me why show this error? Pin
ThatsAlok8-Feb-06 17:57
ThatsAlok8-Feb-06 17:57 
AnswerRe: Could you tall me why show this error? Pin
Shashikant_200629-Jun-06 2:33
Shashikant_200629-Jun-06 2:33 
GeneralRe: Could you tall me why show this error? Pin
lipper10-Jun-08 16:55
lipper10-Jun-08 16:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.