PlatformVB

RASValidateEntryName

The following function will determine if an entry name is valid

 

Declare Function RasValidateEntryName _
      Lib "rasapi32.dll" Alias "RasValidateEntryNameA" _
        (ByVal lpszPhonebook As String, _
        ByVal lpszEntry As String) As Long

If the name is valid and does not already exist it will return 0.

If the entry name already exists it will return 183.  You could use this to check for an existing entry rather than using the RASEnumEntries.

If the name syntax is invalid it will return 123

The following is an example:

Dim rtn As Long
rtn = RasValidateEntryName(vbNullString, "My New Name")
If rtn <> 0 Then
   Debug.Print rtn, VBRASErrorHandler(rtn)
End If

 

See Also: Contents, Introduction, RasEnumEntries, RasErrorHandler.