A Windows Vista forum. Vista Banter

Welcome to Vista Banter.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to ask questions and reply to others posts, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

Go Back   Home » Vista Banter forum » Microsoft Windows Vista » Networking with Windows Vista
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Networking with Windows Vista Networking issues and questions with Windows Vista. (microsoft.public.windows.vista.networking_sharing)

RasSetEntryProperties returns error 816 in Vista



 
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old July 24th 07, 05:24 AM posted to microsoft.public.windows.vista.networking_sharing
erajaysharma@gmail.com
external usenet poster
 
Posts: 2
Default RasSetEntryProperties returns error 816 in Vista

Hi,

I am trying to make a dial up connection in Vista using
RasSetEntryProperties function...but it is returning error code
816.... it runs fine in XP...I am using the following code....Can any
one please tell why this is happening and what should i do to get rid
of it....

Many thanks in advance...
Ajay

struct DIALUP_ICON_PROPERTIES
{
RASENTRY *rasEntry;
DWORD rasEntrySize;
BYTE *deviceInfo;
DWORD deviceInfoSize;
}props;

//getIconProperties returns successfully. problem is with
RasSetEntryProperties
void createDialup()
{
const char *dialupName;
char* driverType;
char* vci;
char* vpi;
char* encapsulation;

dialupName = "Centragate";
driverType = "\"WAN\"";
vci = "0";
vpi = "77";
encapsulation = "8";

if (getIconProperties(_T(""), &props))
{
printf("Can't get default connecton id");
return;
}

props.rasEntry-dwfOptions = RASEO_RemoteDefaultGateway |
RASEO_ModemLights |
RASEO_SecureLocalFiles; // disables file and print
sharing and ms networks
props.rasEntry-dwFramingProtocol = RASFP_Ppp;
props.rasEntry-dwfNetProtocols = RASNP_Ip;
props.rasEntry-dwIdleDisconnectSeconds =
RASIDS_Disabled;
_stprintf(props.rasEntry-szLocalPhoneNumber, _T("%s,%s"), vpi, vci);

// Which dialup device are we going to use?

LPRASDEVINFO lpRasDevInfo = NULL;
DWORD nRasDevInfoSize = 0;
DWORD cRasDevices = 0;

DWORD nRet = RasEnumDevices(NULL, &nRasDevInfoSize, &cRasDevices);
if (nRet == ERROR_BUFFER_TOO_SMALL && nRasDevInfoSize 0)
{
lpRasDevInfo = (LPRASDEVINFO) new BYTE[nRasDevInfoSize];
lpRasDevInfo-dwSize = sizeof(RASDEVINFO);
nRet = RasEnumDevices(lpRasDevInfo, &nRasDevInfoSize, &cRasDevices);
}

if (nRet != 0 || cRasDevices == 0)
{
printf("No RAS devices found");
return;
}

_tcscpy(props.rasEntry-szDeviceType, RASDT_Modem);
_tcscpy(props.rasEntry-szDeviceName, "Conexant USB ADSL WAN Modem");

nRet = RasSetEntryProperties(NULL, dialupName,
props.rasEntry, props.rasEntrySize,
props.deviceInfo, props.deviceInfoSize);

if (nRet != 0)
{
printf("Can't set RAS properties\n");
return;
}
return;
}

//Returns TRUE if failes FALSE if succeeds
BOOL getIconProperties(LPCTSTR iconName, struct DIALUP_ICON_PROPERTIES
*iconProps)
{
RASENTRY *rasEntry = NULL;
BYTE *deviceInfo = NULL;
DWORD rasEntrySize = 0;
DWORD deviceInfoSize = 0;

DWORD nRet
RasGetEntryPropertiesNULL,iconName,NULL,&rasEntryS ize,NULL,&deviceInfoSize);

if (nRet != ERROR_BUFFER_TOO_SMALL || rasEntrySize == 0)
{
printf("RasGetEntryProperties error:
ret=%d,name=%s", nRet, iconName);
return TRUE;
}

rasEntry = (RASENTRY *) new BYTE[rasEntrySize];
if (rasEntry == NULL)
{
return TRUE;
}

rasEntry-dwSize = rasEntrySize;
nRet =
RasGetEntryProperties(NULL,iconName,rasEntry,&rasE ntrySize,NULL,&deviceInfoSize);

if (deviceInfoSize)
{
deviceInfo = new BYTE[deviceInfoSize];
if (deviceInfo == NULL)
{
delete [] rasEntry;
return TRUE;
}
}

// now get the actual properties
nRet = RasGetEntryProperties
(NULL,iconName,rasEntry,&rasEntrySize,deviceInfo,& deviceInfoSize);

// See if we got one.
if (rasEntry == NULL || nRet != 0)
{
if (deviceInfo)
delete [] deviceInfo;
if (rasEntry)
delete [] rasEntry;
printf("RasGetEntryProperties error: ret=%d,name=%s", nRet,
iconName);
return TRUE;
}

iconProps-rasEntry = rasEntry;
iconProps-rasEntrySize = rasEntrySize;
iconProps-deviceInfo = deviceInfo;
iconProps-deviceInfoSize = deviceInfoSize;
return FALSE;
}

  #2 (permalink)  
Old August 3rd 07, 05:56 AM posted to microsoft.public.windows.vista.networking_sharing
erajaysharma@gmail.com
external usenet poster
 
Posts: 2
Default RasSetEntryProperties returns error 816 in Vista

On Jul 24, 10:24 am, wrote:
Hi,

I am trying to make a dial up connection in Vista usingRasSetEntryPropertiesfunction...but it is returning error code816.... it runs fine in XP...I am using the following code....Can any
one please tell why this is happening and what should i do to get rid
of it....

Many thanks in advance...Ajay

struct DIALUP_ICON_PROPERTIES
{
RASENTRY *rasEntry;
DWORD rasEntrySize;
BYTE *deviceInfo;
DWORD deviceInfoSize;

}props;

//getIconProperties returns successfully. problem is withRasSetEntryProperties
void createDialup()
{
const char *dialupName;
char* driverType;
char* vci;
char* vpi;
char* encapsulation;

dialupName = "Centragate";
driverType = "\"WAN\"";
vci = "0";
vpi = "77";
encapsulation = "8";

if (getIconProperties(_T(""), &props))
{
printf("Can't get default connecton id");
return;
}

props.rasEntry-dwfOptions = RASEO_RemoteDefaultGateway |
RASEO_ModemLights |
RASEO_SecureLocalFiles; // disables file and print
sharing and ms networks
props.rasEntry-dwFramingProtocol = RASFP_Ppp;
props.rasEntry-dwfNetProtocols = RASNP_Ip;
props.rasEntry-dwIdleDisconnectSeconds =
RASIDS_Disabled;
_stprintf(props.rasEntry-szLocalPhoneNumber, _T("%s,%s"), vpi, vci);

// Which dialup device are we going to use?

LPRASDEVINFO lpRasDevInfo = NULL;
DWORD nRasDevInfoSize = 0;
DWORD cRasDevices = 0;

DWORD nRet = RasEnumDevices(NULL, &nRasDevInfoSize, &cRasDevices);
if (nRet == ERROR_BUFFER_TOO_SMALL && nRasDevInfoSize 0)
{
lpRasDevInfo = (LPRASDEVINFO) new BYTE[nRasDevInfoSize];
lpRasDevInfo-dwSize = sizeof(RASDEVINFO);
nRet = RasEnumDevices(lpRasDevInfo, &nRasDevInfoSize, &cRasDevices);
}

if (nRet != 0 || cRasDevices == 0)
{
printf("No RAS devices found");
return;
}

_tcscpy(props.rasEntry-szDeviceType, RASDT_Modem);
_tcscpy(props.rasEntry-szDeviceName, "Conexant USB ADSL WAN Modem");

nRet =RasSetEntryProperties(NULL, dialupName,
props.rasEntry, props.rasEntrySize,
props.deviceInfo, props.deviceInfoSize);

if (nRet != 0)
{
printf("Can't set RAS properties\n");
return;
}
return;

}

//Returns TRUE if failes FALSE if succeeds
BOOL getIconProperties(LPCTSTR iconName, struct DIALUP_ICON_PROPERTIES
*iconProps)
{
RASENTRY *rasEntry = NULL;
BYTE *deviceInfo = NULL;
DWORD rasEntrySize = 0;
DWORD deviceInfoSize = 0;

DWORD nRet
RasGetEntryPropertiesNULL,iconName,NULL,&rasEntryS ize,NULL,&deviceInfoSize);

if (nRet != ERROR_BUFFER_TOO_SMALL || rasEntrySize == 0)
{
printf("RasGetEntryProperties error:
ret=%d,name=%s", nRet, iconName);
return TRUE;
}

rasEntry = (RASENTRY *) new BYTE[rasEntrySize];
if (rasEntry == NULL)
{
return TRUE;
}

rasEntry-dwSize = rasEntrySize;
nRet =
RasGetEntryProperties(NULL,iconName,rasEntry,&rasE ntrySize,NULL,&deviceInfoSize);

if (deviceInfoSize)
{
deviceInfo = new BYTE[deviceInfoSize];
if (deviceInfo == NULL)
{
delete [] rasEntry;
return TRUE;
}
}

// now get the actual properties
nRet = RasGetEntryProperties
(NULL,iconName,rasEntry,&rasEntrySize,deviceInfo,& deviceInfoSize);

// See if we got one.
if (rasEntry == NULL || nRet != 0)
{
if (deviceInfo)
delete [] deviceInfo;
if (rasEntry)
delete [] rasEntry;
printf("RasGetEntryProperties error: ret=%d,name=%s", nRet,
iconName);
return TRUE;
}

iconProps-rasEntry = rasEntry;
iconProps-rasEntrySize = rasEntrySize;
iconProps-deviceInfo = deviceInfo;
iconProps-deviceInfoSize = deviceInfoSize;
return FALSE;

}



I have solved this problem....I just added one line "memset(rasEntry,
0,rasEntrySize);" and it started working... Acutally there were some
garbage values in rasEntry structure. Memsetting it solved the
problem...Search for memset(rasEntry,0,rasEntrySize); in the code
below....

BOOL getIconProperties(LPCTSTR iconName, struct
DIALUP_ICON_PROPERTIES
*iconProps)
{
RASENTRY *rasEntry = NULL;
BYTE *deviceInfo = NULL;
DWORD rasEntrySize = 0;
DWORD deviceInfoSize = 0;

DWORD nRet
RasGetEntryPropertiesNULL,iconName,NULL,&rasEntryS ize,NULL,&deviceInfoSize);

if (nRet != ERROR_BUFFER_TOO_SMALL || rasEntrySize == 0)
{
printf("RasGetEntryProperties error:
ret=%d,name=%s", nRet, iconName);
return TRUE;
}

rasEntry = (RASENTRY *) new BYTE[rasEntrySize];
/***********************************************/
memset(rasEntry,0,rasEntrySize);
/***********************************************/
if (rasEntry == NULL)
{
return TRUE;
}

rasEntry-dwSize = rasEntrySize;
nRet =
RasGetEntryProperties(NULL,iconName,rasEntry,&rasE ntrySize,NULL,&deviceInfoSize);

if (deviceInfoSize)
{
deviceInfo = new BYTE[deviceInfoSize];
if (deviceInfo == NULL)
{
delete [] rasEntry;
return TRUE;
}
}

// now get the actual properties
nRet = RasGetEntryProperties
(NULL,iconName,rasEntry,&rasEntrySize,deviceInfo,& deviceInfoSize);

// See if we got one.
if (rasEntry == NULL || nRet != 0)
{
if (deviceInfo)
delete [] deviceInfo;
if (rasEntry)
delete [] rasEntry;
printf("RasGetEntryProperties error: ret=%d,name=%s", nRet,
iconName);
return TRUE;
}

iconProps-rasEntry = rasEntry;
iconProps-rasEntrySize = rasEntrySize;
iconProps-deviceInfo = deviceInfo;
iconProps-deviceInfoSize = deviceInfoSize;
return FALSE;
}

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:04 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.Search Engine Optimization by vBSEO 3.0.0 RC6
Copyright ©2004-2012 Vista Banter.
The comments are property of their posters.