Reputation: 5023
This question is regarding Rasdial and pbk file. I am updating the pbk file using "rassetentryproperties" and dialling through "rasdialdlg".
The below flags decide the parameters of the pbk file inturn responisble for the property of the dial-up connection. I am presetting the flags as:
RasEntry.dwfOptions = 0x00000000;
RasEntry.dwfOptions2 = 0x00000000;
Trying to do as below to set Flag1 and Flag2.
RasEntry.dwfOptions |= (Set Flag1 | Set Flag2)
However, my pbk file entries are not actually setting, as i set above.
Also, for the same code, Win7 pbk and win xp pbk are different. Where i am wrong?
Code Sample for the reference:
BOOL Create_Phone_Book ( LPTSTR DeviceName ) {
DWORD regError;
TCHAR DeviceName[100];
if ( _tcscpy ( DeviceName, DeviceName ) != NULL ) {
Slog ( TEXT ("Strcpy Success"), APISUCCESS );
} else {
Slog ( TEXT ("Strcpy Failed To copy deviceName to DeviceName"), NOLASTERROR);
return FALSE;
}
RASENTRY RasEntry;
DWORD cb;
RASDIALPARAMS RasDialParams;
memset((LPTSTR)&RasEntry, 0, sizeof(RASENTRY));
RasEntry.dwSize = sizeof(RASENTRY);
cb = sizeof(RASENTRY);
regError = RasGetEntryProperties (NULL, TEXT (""), &RasEntry, &cb, NULL, NULL);
if ( regError == ERROR_SUCCESS ) {
Slog ( TEXT ("RasGetEntryProperties Success"), APISUCCESS );
} else {
RAS_ErrorHandler ( regError );
return FALSE;
}
RasEntry.dwfOptions = 0x00000000;
RasEntry.dwfOptions2 = 0x00000000;
RasEntry.dwfOptions |= ( RASEO_IpHeaderCompression | RASEO_ModemLights |RASEO_SwCompression |
RASEO_ShowDialingProgress | RASEO_NetworkLogon | RASEO_DisableLcpExtensions );
RasEntry.dwfOptions2 |= ( RASEO2_UseGlobalDeviceSettings | RASEO2_Internet );
if ( _tcscpy ( RasEntry.szDeviceType, RASDT_Modem ) != NULL ) {
Slog ( TEXT ("Strcpy Success"), APISUCCESS );
} else {
Slog ( TEXT ("Strcpy Failed copy RASDT_MODEM to RasEntry.szDeviceType"), NOLASTERROR);
return FALSE;
}
if ( _tcscpy ( RasEntry.szDeviceName, DeviceName ) != NULL ) {
Slog ( TEXT ("Strcpy Success"), APISUCCESS );
} else {
Slog ( TEXT ("Strcpy Failed copy DeviceName to RasEntry.szDeviceName"), NOLASTERROR);
return FALSE;
}
regError = RasSetEntryProperties( NULL , Dial_Up_Name, &RasEntry, sizeof(RasEntry),NULL, 0);
if ( regError == ERROR_SUCCESS ) {
Slog ( TEXT ("RasSetEntryProperties Succeeded"), APISUCCESS);
} else {
RAS_ErrorHandler ( regError );
return FALSE;
}
memset((LPTSTR)&RasDialParams, 0, sizeof(RasDialParams));
RasDialParams.dwSize = sizeof(RASDIALPARAMS);
if ( _tcscpy (RasDialParams.szEntryName, Dial_Up_Name ) != NULL ) {
Slog ( TEXT ("Strcpy Success"), APISUCCESS);
} else {
Slog ( TEXT ("Strcpy Failed Copy Dial_Up_Name to RasDialParams.szEntryName"), NOLASTERROR);
return FALSE;
}
if ( _tcscpy (RasDialParams.szUserName, TEXT ("")) != NULL ) {
Slog ( TEXT ("Strcpy Success"), APISUCCESS);
} else {
Slog ( TEXT ("Strcpy Failed Copy "" to RasDialParams.szUserName"), NOLASTERROR);
return FALSE;
}
if ( _tcscpy (RasDialParams.szPassword, TEXT ("")) != NULL ) {
Slog ( TEXT ("Strcpy Success"), APISUCCESS);
} else {
Slog ( TEXT ("Strcpy Failed Copy "" to RasDialParams.szPassword"), NOLASTERROR);
return FALSE;
}
regError = RasSetEntryDialParams ( NULL, &RasDialParams, FALSE);
if ( regError == ERROR_SUCCESS ) {
Slog ( TEXT ("RasSetEntryDialParams Success"), APISUCCESS );
} else {
RAS_ErrorHandler ( regError );
return FALSE;
}
return TRUE;
}
Updated 1: Typically, i need to create an Dial-Up connection as i like. Please look at the screen shot attached.
As seen in the snap, i have to set and reset many parameters(Set-Display Progress while connecting, Reset- Prompt for UN and PW).
These two flags use to set and reset whatever we want by "or"ing
RasEntry.dwfOptions
RasEntry.dwfOptions2
So what i do in my code is :
resetting the flag:
RasEntry.dwfOptions = 0x00000000;
RasEntry.dwfOptions2 = 0x00000000;
and to set:
RasEntry.dwfOptions |= ( RASEO_IpHeaderCompression | RASEO_ModemLights
|RASEO_SwCompression | RASEO_ShowDialingProgress |
RASEO_NetworkLogon | RASEO_DisableLcpExtensions );
So, the remaining flags other than the above, will be remained Unset.
Now the problem is, Whatever i am setting in the above steps are not actually setting in the dial-up connection. In another way, some parameters are not set even, if i set in the code.
What should i do to get rid of my problem?
Upvotes: 0
Views: 305