判断有无拨号连接:
#include <windows.h>
#include <stdio.h>
#include <ras.h>
#include <raserror.h>int main()
{
DWORD dwCb = sizeof(RASCONN);
DWORD dwErr = ERROR_SUCCESS;
DWORD dwRetries = 5;
DWORD dwConnections = 0;
RASCONN* lpRasConn = NULL; //
// Loop through in case the information from RAS changes between calls.
//
while (dwRetries--)
{
//
// If the memory is allocated, free it.
//
if (NULL != lpRasConn)
{
HeapFree(GetProcessHeap(), 0, lpRasConn);
lpRasConn = NULL;
}
//
// Allocate the size needed for the RAS structure.
//
lpRasConn = (LPRASCONN) HeapAlloc(GetProcessHeap(), 0, dwCb);
if (NULL == lpRasConn)
{
dwErr = ERROR_NOT_ENOUGH_MEMORY;
break;
}
ZeroMemory(lpRasConn, sizeof(RASCONN));
//
// Set the structure size for version checking purposes.
//
lpRasConn->dwSize = sizeof(RASCONN);
//
// Call the RAS API then exit the loop if we are successful or an unknown
// error occurs.
//
dwErr = RasEnumConnections(
lpRasConn,
&dwCb,
&dwConnections);
if (ERROR_BUFFER_TOO_SMALL != dwErr)
{
break;
}
}
//
// In the success case, print the names of the connections.
//
if (ERROR_SUCCESS == dwErr)
{
DWORD i; printf("The following RAS connections are currently active\n\n");
for (i = 0; i < dwConnections; i++)
{
printf("%s\n", lpRasConn[i].szEntryName);
}
}
else
{
printf("RasEnumConnections failed: Error = %d\n", dwErr);
}
//
// Free the memory if necessary.
//
if (NULL != lpRasConn)
{
HeapFree(GetProcessHeap(), 0, lpRasConn);
lpRasConn = NULL;
}}编译通过,但执行时rasenumconnections返回错误码632——ERROR_INVALID_SIZE。
以上代码是MSDN上面的。看到别人相同的问题有网友提示
1、重启拨号器
——怎样重启拨号器。
2、,#define WINVER >0x500
——还是不行
#include <windows.h>
#include <stdio.h>
#include <ras.h>
#include <raserror.h>int main()
{
DWORD dwCb = sizeof(RASCONN);
DWORD dwErr = ERROR_SUCCESS;
DWORD dwRetries = 5;
DWORD dwConnections = 0;
RASCONN* lpRasConn = NULL; //
// Loop through in case the information from RAS changes between calls.
//
while (dwRetries--)
{
//
// If the memory is allocated, free it.
//
if (NULL != lpRasConn)
{
HeapFree(GetProcessHeap(), 0, lpRasConn);
lpRasConn = NULL;
}
//
// Allocate the size needed for the RAS structure.
//
lpRasConn = (LPRASCONN) HeapAlloc(GetProcessHeap(), 0, dwCb);
if (NULL == lpRasConn)
{
dwErr = ERROR_NOT_ENOUGH_MEMORY;
break;
}
ZeroMemory(lpRasConn, sizeof(RASCONN));
//
// Set the structure size for version checking purposes.
//
lpRasConn->dwSize = sizeof(RASCONN);
//
// Call the RAS API then exit the loop if we are successful or an unknown
// error occurs.
//
dwErr = RasEnumConnections(
lpRasConn,
&dwCb,
&dwConnections);
if (ERROR_BUFFER_TOO_SMALL != dwErr)
{
break;
}
}
//
// In the success case, print the names of the connections.
//
if (ERROR_SUCCESS == dwErr)
{
DWORD i; printf("The following RAS connections are currently active\n\n");
for (i = 0; i < dwConnections; i++)
{
printf("%s\n", lpRasConn[i].szEntryName);
}
}
else
{
printf("RasEnumConnections failed: Error = %d\n", dwErr);
}
//
// Free the memory if necessary.
//
if (NULL != lpRasConn)
{
HeapFree(GetProcessHeap(), 0, lpRasConn);
lpRasConn = NULL;
}}编译通过,但执行时rasenumconnections返回错误码632——ERROR_INVALID_SIZE。
以上代码是MSDN上面的。看到别人相同的问题有网友提示
1、重启拨号器
——怎样重启拨号器。
2、,#define WINVER >0x500
——还是不行
解决方案 »
- 做过VPN拨号的进来看看
- 这样写出来的xml文件为什么在IE打不开诶,用ultraedit和winhex打开都是16进制显示的呢?
- VC+ADO+SQL SERVER读取数据异常
- 续昨日高手进来贴!
- 紧急:请问怎么去掉MediaPlayer的Microsoft的标记?
- 我的mfc42ud.lib没了,谁能mail一份给我?
- 为什么GetAsyncKeyState无法判断键盘弹起???
- 关于waitsingleObject在多线程中的问题?
- (来者有分)请问各位高手,用InstallShield做的安装程序,怎样才能使其在 控制面板|添加删除程序 中不出现
- 请问如何动态修改mfc中button按钮的颜色
- windows下如何支持unicode呢?
- 发什么消息可以改变选中的CTabCtrl的属性页
1、在2000下我定义了 0x501
#define WINVER 0x501
#include "stdafx.h"
#include "windows.h"
#include "stdio.h"
#include "Ras.h"
#include "raserror.h"可还是不行。2、我用的是sdk中的ras.h,是在最前,日期是2003/03应该是最新的了。
还是不行。请继续指教。