Figure 1   WinInet Dial-up Functions

Name Description
InternetAutodial Initiates an unattended dial-up connection using the default phonebook entry
InternetAutodialHangup Disconnects a modem connection initiated by InternetAutodial
InternetDial Initiates a dial-up connection with a specific phonebook entry
InternetHangUp Disconnects a modem connection initiated by InternetDial
InternetGoOnline Prompts the user for permission to initiate a dial-up connection to the given URL
InternetGetConnectedState Retrieves the current state of the Internet connection
InternetSetDialState Sets the current state of the Internet connection


Figure 7   RAS Common Dialog Functions

API Name Description
RasPhonebookDlg Displays the main Dial-Up Networking dialog box. From this modal dialog box, the user can dial, edit, or delete a selected phonebook entry, create a new phonebook entry, or specify user preferences.
RasDialDlg Attempts to establish a RAS connection using a specified phonebook entry and the credentials of the logged-on user. The function displays a stream of dialog boxes that indicate the state of the connection operation.
RasMonitorDlg Displays the Dial-Up Networking Monitor property sheet that describes the status of RAS connections.
RasEntryDlg Displays modal property sheets that allow a user to manipulate phonebook entries. If editing or copying an existing phonebook entry, the function displays a phonebook entry property sheet.


Figure 13   RasDial dwNotifierType Values

dwNotifierType Callback Mechanism
0xFFFFFFFF Windows message
0 RasDialFunc
1 RasDialFunc1
2 RasDialFunc2 (Windows NT 4.0)


Figure 14   Phonebook Entry Functions

Name Description
RasCreatePhonebookEntry Creates a new phonebook entry. The function displays a dialog box in which the user types information about the phonebook entry. (Applications written for Windows NT 4.0 should use RasEntry.)
RasEditPhonebookEntry Edits an existing phonebook entry. The function displays a dialog box in which the user can modify the existing information. (Applications written for Windows NT 4.0 should use RasEntry.)
RasEnumEntries Lists all entry names in a RAS phonebook.
RasRenameEntry Changes the name of an entry in a phonebook.
RasDeleteEntry Deletes an entry from a phonebook.
RasValidateEntryName Validates the format of an entry name. The name must contain at least one non-white-space alphanumeric character.
RasGetEntryDialParams Retrieves the connection information saved by the last successful call to the RasDial or RasSetEntryDialParams function for a specified phonebook entry.
RasSetEntryDialParams Changes the connection information saved by the last successful call to the RasDial or RasSetEntryDialParams function for a specified phonebook entry.
RasGetEntryProperties Retrieves the properties of a phonebook entry.
RasSetEntryProperties Changes the connection information for an entry in the phone book or creates a new phonebook entry.


Figure 15   RasEnumEntries


 BOOL CAddAutoDialAddressDlg::OnInitDialog() 
 {
     CDialog::OnInitDialog();
     LPRASENTRYNAME lpRasEntry;
     DWORD dwBuf, dwEntry, dwRet;
     CString strRet;

     // malloc initial buffer
     dwBuf = sizeof(RASENTRYNAME);
     if ((lpRasEntry = (LPRASENTRYNAME)malloc((UINT)dwBuf)) != NULL) 
     {
     //set size for version tracking
         lpRasEntry->dwSize = sizeof(RASENTRYNAME);
         dwRet = RasEnumEntries(NULL, NULL, lpRasEntry, &dwBuf, &dwEntry);
         if (dwRet == ERROR_BUFFER_TOO_SMALL)
         {
         // buffer too small - realloc size in dwBuf
             if ((lpRasEntry = (LPRASENTRYNAME)realloc(lpRasEntry, 
                               (UINT)dwBuf)) != NULL)
                 dwRet = RasEnumEntries(NULL, NULL, lpRasEntry, &dwBuf, &dwEntry);
             else
             {
         free(lpRasEntry);
         return TRUE;
             }
         }
         else if (dwRet != 0) // other error
         { 
          free(lpRasEntry);
          return TRUE;
         }
     // succeeded
         if (dwRet == 0)  
         {
          //fill in combo box
          for(DWORD nIndex = 0; nIndex < dwEntry; nIndex++)
          {
               CString strEntry;
           strEntry.Format("%s", lpRasEntry[nIndex].szEntryName);
           m_Phonebook.AddString(strEntry);
          }
          if (m_Phonebook.GetCount() > 0) 
               m_Phonebook.SetCurSel(0);
         }
     free(lpRasEntry);
      }
      return TRUE;  
 }


Figure 21   MyAutoDial


 // MyAutoDial.cpp : Defines the initialization routines for the DLL.
 //
 
 #include "stdafx.h"
 #include "MyAutoDial.h"
 #include "CustomAutoDialDlg.h"
 #include <ras.h>
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
 #undef THIS_FILE
 static char THIS_FILE[] = __FILE__;
 #endif
 
/////////////////////////////////////////////////////////////////////////////
 // CMyAutoDialApp
 
 BEGIN_MESSAGE_MAP(CMyAutoDialApp, CWinApp)
     //{{AFX_MSG_MAP(CMyAutoDialApp)
     //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
/////////////////////////////////////////////////////////////////////////////
 // CMyAutoDialApp construction
 
 CMyAutoDialApp::CMyAutoDialApp()
 {
 }
 
/////////////////////////////////////////////////////////////////////////////
 // The one and only CMyAutoDialApp object
 
 CMyAutoDialApp theApp;
 
 void ShowCustomUI(CString& strEntry)
 {
     RASDIALPARAMS RasDialParams;
     BOOL bPassword;
     HRASCONN hRasConn;
     DWORD dwRet;
     CCustomAutoDialDlg dlg;
     
     RasDialParams.dwSize = sizeof(RASDIALPARAMS);
     strcpy(RasDialParams.szEntryName, strEntry);
 
     dwRet = RasGetEntryDialParams( NULL, &RasDialParams, &bPassword);
     dlg.m_strEntry = RasDialParams.szEntryName;
     dlg.m_strUserName = RasDialParams.szUserName;
     dlg.m_strPassword = RasDialParams.szPassword;
 
     if (IDOK == dlg.DoModal())
         dwRet = RasDial(NULL, NULL, &RasDialParams, 0, NULL, &hRasConn);
 }
 
 extern "C" BOOL WINAPI MyAutoDialHandlerA(LPSTR lpszPhonebook, LPSTR lpszEntry,
                                           LPRASADPARAMS lpAutoDialParams, 
                                          LPDWORD lpdwRetCode)
 {
     AFX_MANAGE_STATE(AfxGetStaticModuleState());
     CString strEntry = lpszEntry;
     ShowCustomUI(strEntry);
     *lpdwRetCode = ERROR_SUCCESS
     return TRUE;
 }
 
 extern "C" BOOL WINAPI MyAutoDialHandlerW(LPWSTR lpszPhonebook, LPWSTR lpszEntry,
                                           LPRASADPARAMS lpAutoDialParams, 
                                          LPDWORD lpdwRetCode)
 {
     AFX_MANAGE_STATE(AfxGetStaticModuleState());
     CString strEntry = lpszEntry;
     ShowCustomUI(strEntry);
     *lpdwRetCode = ERROR_SUCCESS;
     return TRUE;
 }