Click here to Skip to main content
15,887,267 members
Articles / Desktop Programming / MFC
Article

Creating Dialup Connections

Rate me:
Please Sign up or sign in to vote.
4.50/5 (8 votes)
29 Aug 20022 min read 136K   5.5K   21   23
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.

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
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionAbout Dial up Connection problem I am facing Pin
ss1965 23-Nov-17 20:31
ss1965 23-Nov-17 20:31 
Dear Seiya Fujji

Read and browsed your article on Internet Dialup Program on Code Project.

I am reaching out to you for a specific reason and problem that I am facing with my dial up connection.

Pls find below a brief text explaining what I am looking forward from you.
---------------
We are using Neoway Modem M660A modules for establishing net connection for PC. Basically our application is to upload Real Time data from Rural Locations to our server. However, we are facing a small problem with this solution and seek your support for the same.

We have USB GSM GPRS Modem using Neoway M660A and PL2303 as TTL to USB Converter.
.
We also have a firmware tool built on VC++ that we use to establish internet connection using a Dial up Connection and also this tool fetches some information like Mobile No, SIM No, IMEI No, Signal Strength and reports the same in the tool screen. The tool establishes the net connectivity using Windows Rasdial command. The tool also Pings our server every 30 Sec to check for connectivity. This is working absolutely fine.

The connection once established may work for 2 hrs / 3 hrs / 30 min / 5 hrs and so on. During this time if we want to manually disconnect the net connectivity we are able to do and also re-establish the connection as and when required. This functionality is working fine using RASDIAL / DISCONNECT command.

However, when the connection is lost on its own / Ping Test fails, for some reasons not known to us we are not able to RE ESTABLISH the net connectivity without re-starting the PC. This is where data uploading from some our locations is not uploading on regular basis as required. It is further observed that the data which is not uploaded gets synced to server immediately the PC is started again.

Our observations and requirements for tool are as under:

1. Once connection is lost, the tool is able to detect the same.

2. We are trying to execute the rasdial / Disconnect command when Ping test fails / disconnection is detected. However as we understand this rasdial / disconnect works only when connection is there but since our connection is already lost, this rasdial / disconnect command is not getting executed.

3. When v try to re establish the connection using rasdial / connect again, we get a message "Access Denied" - Possibly an indication that Com
port is not released as connection is lost on its own.

We are looking forward for suggestion that we can possibly try out to be incorporated in the tool so that our problem of re establishing the connection when it is lost / ping test fails and we are able to have seamless net connection all through out the time when PC is powered on.

Requesting you to pls share your suggestions at the earliest so that we can resolve this problem of not able to establish the connection on disconnection.

Would be highly obliged with your support. Do let me know how u can be helpful to resolve this problem.

Regards
Sulax Shah
shahsulax@gmail.com
QuestionThe source code is unavailable Pin
pham phong9-Dec-13 20:23
pham phong9-Dec-13 20:23 
QuestionProgrmatically Creating New Modem Pin
Rangaraman12-Jul-12 3:34
Rangaraman12-Jul-12 3:34 
GeneralTCP/IP service to modem by remote modem Pin
captainc/c++26-Jun-08 21:42
captainc/c++26-Jun-08 21:42 
QuestionHow to configure the entry created by RAS? Pin
hizfp20-Nov-07 19:57
hizfp20-Nov-07 19:57 
NewsNice article but i am missing a little thing (standardgateway) Pin
SiHot27-Jul-07 3:00
SiHot27-Jul-07 3:00 
Questionthx fro the article,but how to setup a modem by 115200? Pin
7788yy7-May-07 0:07
7788yy7-May-07 0:07 
Generalcreate a new phonebook entry Pin
userppp9-Sep-05 23:49
userppp9-Sep-05 23:49 
General"RasSetEntryProperties" give error 632 Pin
mohsen nourian11-Dec-04 21:31
mohsen nourian11-Dec-04 21:31 
GeneralRe: "RasSetEntryProperties" give error 632 Pin
mohsen nourian14-Dec-04 0:34
mohsen nourian14-Dec-04 0:34 
GeneralRe: "RasSetEntryProperties" give error 632 Pin
Member 8923273-Feb-05 2:58
Member 8923273-Feb-05 2:58 
GeneralRe: "RasSetEntryProperties" give error 632 Pin
drchandrao2pl5-Jul-05 23:13
drchandrao2pl5-Jul-05 23:13 
GeneralRe: "RasSetEntryProperties" give error 632 Pin
Pascal PEYRE22-Dec-10 5:50
Pascal PEYRE22-Dec-10 5:50 
Generalrequest Pin
mascovani15-Oct-04 22:49
mascovani15-Oct-04 22:49 
GeneralRasEntry & Win98 Pin
shoshana11-Jul-04 2:29
shoshana11-Jul-04 2:29 
GeneralRe: RasEntry & Win98 Pin
mohsen nourian11-Dec-04 21:19
mohsen nourian11-Dec-04 21:19 
GeneralA Problem with RAS Entry Pin
shoshana6-May-04 7:09
shoshana6-May-04 7:09 
GeneralRe: A Problem with RAS Entry Pin
Seiya Fujii6-May-04 7:12
Seiya Fujii6-May-04 7:12 
GeneralRe: A Problem with RAS Entry Pin
shoshana6-May-04 7:16
shoshana6-May-04 7:16 
GeneralRe: A Problem with RAS Entry Pin
michael_PPCO7-Jul-04 8:04
michael_PPCO7-Jul-04 8:04 
GeneralRe: A Problem with RAS Entry Pin
shoshana7-Jul-04 11:09
shoshana7-Jul-04 11:09 
GeneralGood article Pin
Nish Nishant18-Sep-03 1:24
sitebuilderNish Nishant18-Sep-03 1:24 
GeneralDisabling Multilink on Win2K. Pin
Tili18-Nov-02 0:58
Tili18-Nov-02 0:58 

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.