Click here to Skip to main content
Click here to Skip to main content

Tagged as

Opening a Dial-Up connection

, 13 Jan 2000
Rate this:
Please Sign up or sign in to vote.
How to open a new dialup connection using RasDial
  • Download demo project - 10 Kb
  • <!-- Article Starts -->

    There is a code for Dial-Up connection. Alexander Fedorov discusses in his article Calling RasHangUp without errors how to disconnect a dial-up connection. This is other part of same problem (accessing the internet via phone line). This task can be done by using the CInternetSession::GetFtpConnection() function for example, but only if all parameters in the dial-up dialog are present (but then you can't set the username, password and phone number programatically).

    To use this function you must include the "ras.h" and "raserror.h" header files and link with rasapi32.lib.

    bool DialUp() 
        // Fill RASDIALPARAMS structure
        RASDIALPARAMS rdParams;
        rdParams.dwSize = sizeof(RASDIALPARAMS);
        rdParams.szEntryName[0] = '\0';
        lstrcpy(rdParams.szPhoneNumber, szPhoneNumberToDial);
        rdParams.szCallbackNumber[0] = '\0';
        lstrcpy( rdParams.szUserName, szUserName );
        lstrcpy( rdParams.szPassword, szPassword );    
        rdParams.szDomain[0] = '\0';
        HRASCONN hRasConn = NULL;
        DWORD dwRet = RasDial( NULL, NULL, &rdParams, 0L, NULL, &hRasConn );
        // Everything OK?
        if (dwRet == 0)  
            return true;    
        // Error occurred - get error description and alert user
        char  szBuf[256];
        if (RasGetErrorString( (UINT)dwRet, (LPSTR)szBuf, 256 ) != 0 )
            wsprintf( (LPSTR)szBuf, "Undefined RAS Dial Error (%ld).", dwRet );
        RasHangUp( hRasConn );
        AfxMessageBox( NULL, (LPSTR)szBuf, "Error", MB_OK | MB_ICONSTOP );
        return false;

    Note that here I'm using the synchronous version (the fifth parameter of RasDial() is NULL). The updated version can use a pointer to the RasDialFunc() function instead, and then RasDial() returns immediately and calls RasDialFunc() when WM_RASDIALEVENT occurs.


    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


    About the Author

    Mileta Radenovic
    Software Developer (Senior)
    Canada Canada
    No Biography provided

    Comments and Discussions

    Suggestionyes this can also be tricky in SEO PinmemberRanvir Sharma26-Dec-13 0:41 
    GeneralProblem with proxy Pinmembermahila7-Jan-06 0:18 
    GeneralNice Pinmembereuacela12-Sep-04 12:51 
    GeneralWin 98 &amp; RasDial Pinmembershoshana13-Jul-04 1:55 
    Hello all,
    I use this program in WinXP and it works very well. But when I use it in Win98, I get an answer that the entry is not found in the address book.
    Thanks for every help.
    - I wish not getting answers from jews on saturday.
    GeneralRe: Win 98 & RasDial Pinmemberleechangjun29-Mar-11 22:51 
    GeneralRegarding creating Dialup via Visual Basic Pinmemberautometa3-Feb-04 0:31 
    GeneralNewer ras.h Pinmembernikouhl6-Aug-03 6:26 
    GeneralGetting the IP address from the Remote PC PinmemberLeon v Wyk10-Apr-03 2:40 
    GeneralPlease help Pinmemberbowetech14-Feb-03 17:25 
    GeneralRe: Please help PinmemberLeon v Wyk10-Apr-03 2:13 
    GeneralThis code overwrites original PhoneBook PinmemberTili18-Jul-02 16:57 
    QuestionWhat if i dial ¶ÌÈ©¥ PinmemberAnonymous21-Feb-02 19:56 
    GeneralWindows 98 as dial-up server PinmemberFelvi20-Feb-02 17:01 
    GeneralRe: Windows 98 as dial-up server PinmemberLeon v Wyk10-Apr-03 2:17 
    GeneralRE: DialUp PinsussMartijn Hoogendoorn6-Mar-00 11:42 
    GeneralMake link dynamic PinsussBrad Bruce15-Jan-00 6:25 

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

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

    | Advertise | Privacy | Terms of Use | Mobile
    Web02 | 2.8.150327.1 | Last Updated 14 Jan 2000
    Article Copyright 2000 by Mileta Radenovic
    Everything else Copyright © CodeProject, 1999-2015
    Layout: fixed | fluid