Share via


Creating or Changing a Phone-Book Entry (Windows Embedded CE 6.0)

1/6/2010

You can use use the RasSetEntryProperties function to create or change phone-book entries.

To create or change registry phone-book entries

  1. Call RasValidateEntryName to be sure that the name does not exist.

  2. If you are editing an existing entry, call RasGetEntryProperties to retrieve the existing configuration.

  3. Call RasSetEntryProperties to set the new configuration. The following glist shows how the parameters should be set:

    • The lpszName parameter should point to the null-terminated string containing the entry name in the lpszEntry parameter*.* If the existing name matches an existing entry, RasSetEntryProperties modifies the entry properties. If the entry does not exist, the function creates a new entry.
    • The lpszEntry parameter should point to a RASENTRY structure, which should be filled with data for the connection, including the telephone number, device type, and name.
    • The lpbDeviceInfo and dwDeviceInfoSize parameters can be used to set Telephony API (TAPI) device configuration data.

Creating a Phone-Book Entry Example

The following code example shows how to create a phone-book entry.

int CreateRasEntry (LPTSTR lpszName)
{
  DWORD dwSize,
        dwError;
  TCHAR szError[100];
  RASENTRY RasEntry;
  RASDIALPARAMS  RasDialParams;

  // Validate the format of a connection entry name.
  if (dwError = RasValidateEntryName (NULL, lpszName))
  {
    wsprintf (szError, TEXT("Unable to validate entry name.")
              TEXT(" Error %ld"), dwError);  

    return FALSE;
  }

  // Initialize the RASENTRY structure.
  memset (&RasEntry, 0, sizeof (RASENTRY));

  dwSize = sizeof (RASENTRY);
  RasEntry.dwSize = dwSize;

  // Retrieve the entry properties.
  if (dwError = RasGetEntryProperties (NULL, TEXT(""),      
                      (LPBYTE)&RasEntry, &dwSize, NULL, NULL))  
  {
    wsprintf (szError, TEXT("Unable to read default entry properties.")
              TEXT(" Error %ld"), dwError);
    return FALSE;
  }

  // Insert code here to fill the RASENTRY structure.
  // ...
  
  // Create a new phone-book entry.
  if (dwError = RasSetEntryProperties (NULL, lpszName, 
                      (LPBYTE)&RasEntry, sizeof (RASENTRY), NULL, 0))
  {
    wsprintf (szError, TEXT("Unable to create the phonebook entry.")
              TEXT(" Error %ld"), dwError);
    return FALSE;
  }

  // Initialize the RASDIALPARAMS structure.
  memset (&RasDialParams, 0, sizeof (RASDIALPARAMS));
  RasDialParams.dwSize = sizeof (RASDIALPARAMS);
  _tcscpy (RasDialParams.szEntryName, lpszName);
  
  // Insert code here to fill up the RASDIALPARAMS structure.
  // ...

  // Change the connection data.
  if (dwError = RasSetEntryDialParams (NULL, &RasDialParams, FALSE))
  {
    wsprintf (szError, TEXT("Unable to set the connection information.")
              TEXT(" Error %ld"), dwError);
    return FALSE;
  }

  return TRUE;
}

See Also

Concepts

Phone-Book Operation