65.9K
CodeProject is changing. Read more.
Home

Creating Dialup Connections

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.50/5 (8 votes)

Aug 30, 2002

2 min read

viewsIcon

137357

downloadIcon

5494

Describes how to create a new phone-book entry, and set it up with the user profile.

Sample Image

Introduction

Recently I worked on the dialup APIs, and I noticed that many people are having difficulty using some of the RAS functions. Here, I decided to present how to create a new phone-book entry. The key functions are RasSetEntryProperties() to create a phone-book entry, and RasSetEntryDialParams() to store the username and the password in it. There are a couple more RAS functions that are used, but I wrapped them in the very simple functions to show you how to use them correctly.

API Reference

CreateRasEntry

Use this function to create a new phone-book entry. 

BOOL CRasEntry::CreateRasEntry(CString strEntryName, RASENTRY &RasEntry);

Parameters

  • strEntryName: Specifies a string containing the phone-book entry to use to establish the connection.
  • RasEntry: RASENTRY structure that contains the new connection data to be associated with the phone-book entry specified by the strEntryName parameter.

EnumModem

Returns the name and type of all available RAS-capable devices.

BOOL CRasEntry::EnumModem(char *szDeviceType, CStringArray &strDevArray);

Parameters

  • szDeviceType: Specifies a RAS device type. These are the available types: RASDT_Modem, RASDT_Isdn, RASDT_X25, RASDT_Vpn, and RASDT_Pad. For the dialup connection, you should use RASDT_Modem ("modem").
  • strDevArray: If this function returns TRUE, strDevArray will contain the name of all the RAS devices.

GetCountryInfo

Retrieves country-specific dialing information from the Windows Telephony list of countries. Provide the country ID before calling this function. If the function succeeds, it returns the country ID.

DWORD CRasEntry::GetCountryInfo(DWORD dwCID, RASCTRYINFO &RasCTryInfo, char *szCountryName);

Parameters

  • dwCID: Specifies a string containing the phone-book entry to use to establish the connection.
  • RasCTryInfo: Specifies a string containing the user's user name.
  • szCountryName: Specifies a string containing the user's password.

In order to retrieve all the countries, create a while loop like this:

RASCTRYINFO RasCTryInfo;
char szCountryName[256];
DWORD dwCountryID = 1;
while(GetCountryInfo(dwCountryID, RasCTryInfo, szCountryName))
{
    dwCountryID = RasCTryInfo.dwNextCountryID;
}

SetEntryDialParams

Specifies the user name and the password for the specified phone-book entry.

BOOL CRasEntry::SetEntryDialParams(CString strEntryName, CString strUsername, CString strPassword, BOOL bRemovePassword);

Parameters

  • strEntryName: Specifies a string containing the phone-book entry to use to establish the connection.
  • strUsername: Specifies a string containing the user's user name.
  • strPassword: Specifies a string containing the user's password.
  • bRemovePassword: Indicates if the password needs to be stored. If bRemovePassword is TRUE, the password will not be saved.