|
为何用 RasSetEntryProperties 函数创建拨号连接时老是返回ERROR_INVALID_SIZE,请高手们指点
[复制链接]
下面是代码:
RASENTRY RasEntry;
RASDIALPARAMS RasDialParams;
HRASCONN hRasConn=NULL;
DWORD dwSize;
DWORD dwError;
TCHAR szError[100] = {0};
TCHAR szMsg[100] = {0};
// Initialize the RASENTRY structure.
dwSize=sizeof(RASENTRY);
memset (&RasEntry, 0, dwSize);
RasEntry.dwSize=dwSize;
RasEntry.dwfOptions=0;
_tcscpy(RasEntry.szLocalPhoneNumber, _T("*99#"));
RasEntry.dwfNetProtocols=RASNP_Ip;
RasEntry.dwFramingProtocol=RASFP_Ppp;
_tcscpy(RasEntry.szDeviceType,RASDT_Modem);
_tcscpy(RasEntry.szDeviceName, _T("GPRS Modem"));
// Create a new phone-book entry.
dwError=RasSetEntryProperties(NULL, _T("My Dialer"), &RasEntry, sizeof(RASENTRY), NULL, 0);
if (dwError!=0)
{
return(FALSE);
}
返回的dwError值为632,我查过Raserror.h,632中ERROR_INVALID_SIZE,意思是我的结构大小传的不对。网上搜了一下相关的贴子,有人说由于windows版本及SDK版本的问题,不能直接用sizeof(RASENTRY)作为RasEntry.dwSize使用,而要先用RasGetEntryProperties(NULL, NULL, NULL, &dwEntrySize, NULL, NULL)获取size,然后把dwEntrySize赋给RasEntry.dwSize,可我试过后,居然返回87,我查过raserror.h,相关错误码是从600开始的,没有87,很奇怪的错误。不知哪位大侠碰到过类似的问题,是如何解决的,谢谢!
|
|