Changing an Existing Phone-Book Entry

The RasRenameEntry function renames a phone-book entry in the registry, while the RasDeleteEntry function deletes an entry. To verify if the string is in the correct format, the application can use the RasValidateEntryName function.

    To change a registry phone-book entry

  1. Call RasValidateEntryName to verify the new name.
  2. Call the RasRenameEntry function to change the name.
  3. The return value is zero if successful, and a RAS error value if not.

The following code example shows how to change an existing phone-book entry.

BOOL RenameRasEntry (LPTSTR lpszOldName, LPTSTR lpszNewName)

{
  DWORD dwError;            // Return code from functions 
  TCHAR szError[120];       // Buffer for error message 

  if (dwError = RasValidateEntryName (NULL, lpszNewName))
  {
    wsprintf (szError, TEXT("Entry name validation failed: %ld"), 
              dwError);
    return FALSE;
  }

  if (dwError = RasRenameEntry (NULL, lpszOldName, lpszNewName))
  {
    wsprintf (szError, TEXT("Unable to rename entry: %ld"), dwError);
    return FALSE;
  }

  return TRUE;
}