专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > DotNet Exception

RasSetEntryProperties函数返回632错误

发布时间:2011-06-26 20:26:52 文章来源:www.iduyao.cn 采编人员:星星草

 RasSetEntryProperties函数返回632错误:

目前在修改一个mfc网络程序(使其支持windows7),其中用到网络虚拟拨号功能,但是我在调用RasSetEntryProperties这个方法时,总是会报错误
“632”,我在错误查找里了解是“The requested interface is not supported”,可是网络上搜索却有人说是数据参数结构错误。
代码如下
DWORD CreateRASEntry()
{
DWORD Err = ERROR_SUCCESS;
RASENTRY* pRasEntry = (RASENTRY*)malloc(SIZEOF_RASENTRY);
if (!pRasEntry)
{
DebugPrintString("Error: CreateRASEntry - Could not allocate memory for pRasEntry");
return ERROR_NOT_ENOUGH_MEMORY;
}
memset(pRasEntry,0,SIZEOF_RASENTRY);
pRasEntry->dwSize = sizeof(pRasEntry)/*SIZEOF_RASENTRY*/;

strcpy(pRasEntry->szLocalPhoneNumber,LOCAL_PHONE_NUMBER);
pRasEntry->dwfOptions =  RASEO_ShowDialingProgress | RASEO_SwCompression;

pRasEntry->dwfNetProtocols = RASNP_Ip;

pRasEntry->dwFramingProtocol = RASFP_Ppp;

strcpy(pRasEntry->szDeviceType, RASDT_Isdn);

char szSystemLastDeviceName[255];
dwGetSystemLastRasDevice(szSystemLastDeviceName, 255);

strcpy(pRasEntry->szDeviceName, szSystemLastDeviceName);

pRasEntry->dwSubEntries = 0;
pRasEntry->dwType = RASET_Phone;

Err = ERROR_SUCCESS;

szRasentryName[0] = '\0';
if(IsWin64())
{
strncat(szRasentryName,RASENTRY_NAME_64,128);
}
else
{
strncat(szRasentryName,RASENTRY_NAME_32,128);
}

Err = RasSetEntryProperties (NULL, szRasentryName, pRasEntry,pRasEntry->dwSize, NULL, 0);
if (ERROR_SUCCESS != Err)
{
DebugPrintString("Error: CreateRASEntry - failed, errorcode = %d", Err);
free(pRasEntry);
return Err;
}
DebugPrintString("Info: CreateRASEntry - Success");
free(pRasEntry);

vSetRASAutoDialDefault(szRasentryName);

return Err;
}
这段代码在windowsxp下面执行没问题,但是到了windows7就会报错
哪位大虾帮忙看一下,到底有什么问题。

------解决方法--------------------------------------------------------
应该使用RasGetEntryProperties取得size
参考:

The size of the RASENTRY structure on the build plaform (WINVER). Use
RasGetEntryProperties() to get the size of a RAS entry in a
platform-independent way...

DWORD dwEntryInfoSize = 0;
(void) RasGetEntryProperties(NULL, NULL, NULL, &dwEntryInfoSize, NULL,
NULL);

....and use dwEntryInfoSize instead of sizeof(RASENTRY).


 

 

    
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: