CUT_RAS::SetEntryProperties
int SetEntryProperties(LPCSTR szEntryName, LPRASENTRY pRasEntry,DWORD nRasEntryLen = sizeof(RASENTRY)
Parameters
szEntryName |
Name of the phonebook entry to add or update. |
pRasEntry |
A pointer to a RASENTRY structure which contains the data for the entry to add or update. The dwSize member of the structure must be set to sizeof(RASENTRY). NOTE: This can optionally be followed by a list of alternative phone numbers. |
nRasEntryLen |
Size of the RAS entry. Defaults to sizeof(RASENTRY). It can be set if a list of alternative phone numbers are also available. |
Return Value
UTE_SUCCESS |
Operation completed successfully. |
UTE_ERROR |
Function failed (see GetLastRASError for more details). |
UTE_RAS_LOAD_ERROR |
Unable to load the RAS DLLs. |
Remarks
Call this function to create or modify a phonebook entry. If the given entry does not exist then a new one is created, but if the entry already exists then it is overwritten. This function takes a pointer to a RASENTRY structure which contains all of the fields required to make a complete phonebook entry except for the user name and password (see SetDialEntryParams). NOTE: the RASENTRY structure can be followed by an array of null-terminated alternate phone number strings. The last string is terminated by two consecutive null characters. The dwAlternateOffset member of the RASENTRY structure contains the offset to the first string.
Set the nRasEntryLen
parameter to the total length of the given data. nRasEntryLen
has a default value of sizeof(RASENTRY).
Use ValidateEntryName to make sure
that a new entry name is valid.
See also: GetEntryProperties | GetEntry
Example
/*******************************************************************
Read the values from the dialog's controls and update the
Ras Entry structure and then set the properties of the specified entry.
This sample code only adds new entries. For clarity, if the entry
exists it is not modified (you can modify the code to
alter existing entries).
*******************************************************************/
void CAddModifyEntry::OnOk()
{
// read the values from the dialog's controls and update the
// Ras Entry structure then Set the Properties
if (m_bModify){
// Update the Dialogs controls based on the entry's Data
GetDlgItemText(IDC_ENTRYNAME,m_szEntryName,RAS_MaxEntryName);
if (m_pRas->DoesEntryExist (m_szEntryName) == UTE_SUCCESS)
{
// ask if the user wants to modify the existing entry
MessageBox("An entry with this name already exists");
}else
{
if (m_pRas->ValidateEntryName (m_szEntryName) == UTE_SUCCESS)
{
// get the new phone number
GetDlgItemText(IDC_PHONE_NUMBER,m_rasEntry->szLocalPhoneNumber,RAS_MaxPhoneNumber);
// get the new are code number
GetDlgItemText(IDC_AREA_CODE,m_rasEntry->szAreaCode,RAS_MaxAreaCode);
if (m_pRas->SetEntryProperties(m_szEntryName,m_rasEntry)== UTE_SUCCESS)
{
// now set the Dialup properties
LPRASDIALPARAMS pDialParam = new RASDIALPARAMS[sizeof(RASDIALPARAMS)+1];
memset(pDialParam,0,sizeof(RASDIALPARAMS));
pDialParam->dwSize= sizeof(RASDIALPARAMS);
// Set the Entry name
strcpy(pDialParam->szEntryName ,m_szEntryName);
// set the phone number
GetDlgItemText(IDC_PHONE_NUMBER,pDialParam->szPhoneNumber,RAS_MaxPhoneNumber);
// set the user name
GetDlgItemText(IDC_USER,pDialParam->szUserName,UNLEN);
// set the password string
GetDlgItemText(IDC_PASSWORD,pDialParam->szPassword,PWLEN);
// now update the entry's Dialup parameters
m_pRas->SetDialEntryParams (m_szEntryName,pDialParam,FALSE);
delete [] pDialParam ;
CDialog::OnOK ();
}
}else // the selected name is not valid name
MessageBox("Name not valid");
}
}else // if we are not adding a new entry then just exit
CDialog::OnOK ();
}