A Remote Access Service (RAS) Client Class

This article was contributed by Qing Zhang qzhang7@tfn.net.

Remote Access Service (RAS), also as "Dial-Up Networking" in Windows 95/98, lets users at remote locations work as if connected directly to a computer network, accessing one or more RAS servers.

The Microsoft® Win32® RAS API enables RAS client applications to perform the tasks such as display RAS common dialog boxes, start and end a RAS connection, operate to phone-book, work with entries in the RAS AutoDial mapping database, and get RAS information, etc. For Windows NT version 4.0, the Win32 API also provides support for RAS server administration and connection management. Windows 95 does not provide RAS server support.

This Article introduces a RAS client class, CRasClient, which wraps the client part functions of RAS API, and supports for both Windows 95/98 and NT4.0. In order to make your application using CRasClient works on both Windows 95/98 and Windows NT4.0, instead of wrapping some RAS API functions like RAS common dialog boxes, phone-book (.PBK) file operation, the class doesn't include the functions which only work on Windows NT4.0. S you don't need to worry about the operating system when you include this class in your application. And it is easy to add Dial-Up Networking common dialog boxes, such as establishing and monitoring connections, or working with phone-book entries, by yourself in your application.

The functions CRasClient supported include:

  1. Create Phone-book entry, and set the properties.
  2. Get information about RAS-capable devices configured on the local computer.
  3. Start and end RAS connection operation.
  4. Get information about existing RAS connections
  5. Get error message and notifications when a RAS connection begins or ends.

The RAS API functions wrapped include:

  • RasGetEntryProperties
  • RasEnumDevices
  • RasSetEntryProperties
  • RasDial
  • RasGetErrorString
  • RasEnumConnections
  • RasValidateEntryName
  • RasGetConnectStatus
  • RasHangUp

The CRasClient header list below:

class CRasClient

	HRASCONN m_ConnectionHandle;

	long GetDeviceCount();
	BOOL GetDeviceNameType(int nIndex, CString& strName, CString& strType);
	BOOL GetModemName(CString* strModemNameArray);
	long GetModemCount();
	DWORD ChangeEntryName(CString strOldName, CString strNewName);
	DWORD CreateNewEntry(CString strEntry, CString strDeviceType, 
		CString strDeviceName, 
		DWORD dwfNetProtocols, DWORD dwFrameProtocal, 
		CString strLocalPhone, CString strPhoneBook = _T(""));
	DWORD SetEntryOption(CString strEntry, DWORD dwfOptions, 
		BOOL bSet = TRUE, CString strPhoneBook = _T(""));
	DWORD SetEntryServerProtocal(CString strEntry, 
		DWORD dwfNetProtocols, CString strPhoneBook = _T(""));
	DWORD SetEntryIPAddress(CString strEntry, int nIPType,
		BYTE a, BYTE b, BYTE c, BYTE d, CString strPhoneBook = _T(""));
	DWORD GetEntryProperties(CString strEntry, RASENTRY* lpRasEntry
		, LPTSTR lpszPhoneBook = NULL);
	DWORD RasDialSyn(CString strEntry, CString strPhoneNumber = _T(""),
		CString strUserName = _T(""), CString strPassword = _T(""), CString strDomain = _T(""), 
		CString strPhoneBook = _T(""));
	DWORD RasDialAsyn(CString strEntry, LPVOID lpvNotifer, CString strPhoneNumber = _T(""),
		CString strUserName = _T(""), CString strPassword = _T(""), CString strDomain = _T(""), 
		CString strPhoneBook = _T(""));
	DWORD RasDialAsynCallback1(CString strEntry, LPVOID lpvNotifer, CString strPhoneNumber = _T(""),
		CString strUserName = _T(""), CString strPassword = _T(""), CString strDomain = _T(""), 
		CString strPhoneBook = _T(""));
	BOOL GetRasStatusString(CString &strStatus, BOOL& bConnected);
	DWORD GetRasErrorString(CString &strError);
	DWORD GetRasErrorStringByErrorCode(DWORD dwError,
		DWORD dwExtendError, CString &strError);
	BOOL HangUpConnection(CString strEntry);
	BOOL GetRasConnection(CString strEntry, HRASCONN &hrasConn);

To add the support of Dial-Up Networking to your application, normally you need to implement the tasks as following:

  1. Create a phone-book entry for dialing up.
  2. Set the phone-book entry properties, like phone number, user name, device to use for dialing, dial-up server type, network protocol, etc... just like you set your Dial-up Networking in your desktop.
  3. Start to dial, and try to make connection.
  4. End your connection.

How to use CRasClient class?

Simply add CRasClient.h and CRasClient.cpp to your project, make an instance of the class, and call the functions you need. You don't need to add the library "rasapi32.lib" to your project setting.

About Demo Project

The demo project, "RasDemo", sets up a PPP dial-up networking connection with a Dial-Up Server (Windows 95/98), or RAS Server (Windows NT4.0) using modem connection. After connect, two computers will be able to see each other just like wire network. The protocol "RasDemo" uses is NetBEUI, dial-up server type is PPP.

How to run RasDemo?

  1. Setup your Dial-Up Server. For Windows 95/98, go to "My Computer/Dial-Up Networking", under the menu "Connections", you can find "Dial-Up Server...". You shall have Windows 95 Plus! or Windows 98 installed to have this server. Also make your Dial-Up Adapter attached to NetBEIU in your computer's network setting, and "File and Print Sharing" enabled.
  2. Run RasDemo, enter the phone number you use to dial, click "Connect". If it connects successfully, you will see the dial-up networking monitor icon on task tray, if not, you will get error messages.

How RasDemo works?

When RasDemo Dialog box appears, the modem names which RAS can use to dial fill a combo box, the function CRasDemoDlg::FillModemCombo() is called.

BOOL CRasDemoDlg::FillModemCombo()
	int iModemCount = m_pRas->GetModemCount();
	if(iModemCount == 0)
		m_strStatus = "There is no modem installed in your computer!";
		return FALSE;
	else if(iModemCount < 0)
		m_strStatus = "Fail to get modem count!";
		return FALSE;
	CString* strName = new CString[iModemCount];
	BOOL bResult = m_pRas->GetModemName(strName);
		for(int i = 0; i < iModemCount; i++)
		m_strStatus = "Fail to get Modem name!";
	delete []strName;
	return bResult; 

When you click the button "Connect", the code below shows what happens.

void CRasDemoDlg::OnConnectBtn() 
	// TODO: Add your control notification handler code here
	m_bUserCancel = FALSE;
	CString strEntry = "My Network";
	HRASCONN hrasConn;
		if(!m_pRas->GetRasConnection(strEntry, hrasConn))

It tries to create a new entry call "My Network" in your default phone-book, and set the properties.

BOOL CRasDemoDlg::CreateDialUpEntry()
	CString strEntry = "My Network";
	if(m_pRas->CreateNewEntry(strEntry, "modem",
		m_strModemName, RASNP_NetBEUI, RASFP_Ppp, m_strPhone) 
		DWORD dwfOptions = RASEO_SwCompression | 
			RASEO_RequireEncryptedPw | RASEO_RequireMsEncryptedPw |
		if(m_pRas->SetEntryOption(strEntry, dwfOptions, TRUE) != 0) 
			m_strStatus = "Fail to Set My Network Entry!";
			return FALSE;
	return TRUE;

Then check to see if the connection is already existed for that entry. If not, try to make an asynchronous dial operation: the call returns immediately. You shall supply a callback function, we call rasCallback1 here. Before the connection is established, the window also shows the text messages about the dialing progress.

BOOL CRasDemoDlg::DialUpNetwork()
	m_dwError = 0;
	CString strEntry = "My Network";
	DWORD dwError = m_pRas->RasDialAsynCallback1(strEntry, 
		rasCallback1, m_strPhone, m_strUser, m_strPasswd);

	BOOL bLoop = TRUE;
	BOOL bConnected = FALSE;
			return FALSE;

		bLoop = !(m_pRas->GetRasStatusString(m_strStatus, bConnected));

		if(m_dwError != 0)
			m_pRas->GetRasErrorStringByErrorCode(m_dwError, m_dwExtendError, m_strStatus);
			AfxMessageBox("Error: " + m_strStatus);
			return FALSE; 

		return TRUE;
		return FALSE;

If you click the "Cancel" to disconnect the connection, it calls CRasClient::HangupConnection(CString strEntry) to disconnect.


The Win32 RAS functions are in RASAPI32.DLL. You can revise CRasClient to load this DLL explicitly by using LoadLibrary if RAS is not installed. Shall you want to know how to do this to CRasClient, drop me a mail.

CRasClient is tested under Windows 95, Windows 98, and Windows NT 4.0 SP3 using modem connection. Built by Visual C++ 5.0.

Download demo project - 49 KB

Download source - 5 KB


  • KD34+7+5 irresistibility 6 dig hair power gold to destroy thunderbolt 13 Lian Sheng0

    Posted by xvenagfxwx on 05/17/2013 06:35pm

    KD34+7+5 irresistibility 6 dig hair power gold to destroy thunderbolt 13 Lian Sheng Beijing time on March 20, force of field of the guest that dig gold takes thunderbolt, those who obtained the Shi Jilu that start a group 13 Lian Sheng. Thunderbolt of the 114- that dig gold 104 Dig gold (47-22) is obtained 13 Lian Sheng, this is them since joining NBA the longest record. Peaceful - Lawson took 25 minutes, kenneth - Faliaide 13 minutes 15 backboard, amount to Nero - add Linali 13 minutes 8 backboard, andre - Yi Ge Da pulls 10 minutes. The Andre that the reserve comes on the stage - rice carves 9 20 cent, secondary attack and 7 bank, gu Wei Er - wheat radical 11 minutes. [url=http://jordanscheap.page4.me/]air jordans cheap[/url] Thunderbolt (50-18) 3 Lian Sheng is stopped. Kevin - Du Lan got 7 34 cent, backboard and 5 secondary attack especially, lasaier - Weisibuluke 25 minutes of 6 second secondary attack, saierji - Yibaka gets hurt last times from, got 6 minutes, kevin - Martin 14 minutes. Since digging gold to join NBA from 1976, the longest Lian Sheng is 12, had chased after yesterday smooth. In 1969-70 sports season, dig gold to ever was obtained 15 Lian Sheng, but they return be subordinate to to belong to ABA in those days. Digging gold is the team that the minority in alliance can contend with thunderbolt, degree of before this two pass a barrier. Recently in engage in a battle, it is by right of Lawson before end of a show of 0.2 seconds jump the win by a narrow margin that send gift. Today is two teams surpass the last fight hand to hand in convention, although carry back of a chair on the back to fight,dig gold, but still energy is sheer. First thunderbolt precedes with 34-26. Dig gold to carry attack rate, be opposite with dozens thunderbolt is big attack, in the 2nd narrow difference. When this section still has 1 minute of 37 seconds, du Lan is special two punish two in, thunderbolt still precedes with 64-58, yi Ge Da pulls the relay in sky to buckle basket to return with one ball, filling basket of dust heart after this is procurable in the law, the small climax that digs Jin Yibo 8-1 ends this red-letter day, first half lags behind with 65-66 only. Thunderbolt the second half hits the target rate drop, after the 3rd hit 4 minutes, they an one ball in casting. When this section still has 8 minutes of 11 seconds, lawson strikes back quickly, go up after basket is procurable, dig gold to be exceeded with 76-68. Bilateral difference achieves 11 minutes for a time, thunderbolt connects 4 minutes before this part ends, before 3 lag behind with 82-89. The struggle hard when digging gold to was added yesterday just beats an ox, but do not fall on physical strength ahull, last still can retain the antagonism of high strenth. This section spends half, lawson is cast repeatedly belt punish take below 3 minutes, dig gold to precede with 102-92. When Yi Ba gets stuck to still have in this section 5 minutes, get hurt from, nevertheless, thunderbolt narrows for a time difference, when this section still has 4 minutes of 08 seconds, lag behind with 97-102 only. The after this that dig gold is successive bos of shoot a basket, but rob next bank, and thunderbolt fails inside 3 minutes shoot a basket hits the target, when the match still has 1 minute, dig gold to pull open difference once more with 109-98. When the match still has 41.3 seconds, du Lan just buckles basket especially procurable, but had returned day lack art. (responsibility edits: A gleam of fights)

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date