#include "stdafx.h"
#include <windows.h>
#include <ras.h>
#include <rasError.h>
#pragma comment(lib,"rasapi32.lib")
//一段自动断开adsl的例子
int _tmain(int argc, _TCHAR* argv[])
{ DWORD dwConnections;
RASCONN rasconn;
DWORD dwSize;
DWORD dwSuccess; rasconn.dwSize = sizeof(RASCONN);
dwSize = rasconn.dwSize;
dwSuccess = RasEnumConnections(&rasconn,&dwSize,&dwConnections);
//dwConnections总是返回0,在vc6.0下面就返回1
if(dwSuccess==0)
{
if(dwConnections)
{
RasHangUp(rasconn.hrasconn);
}
} return 0;
}
你多建几个呢?
RasEnumConnections的返回值是0??
看看函数调用成功了没?GetLastError()
但是不知道为什么要这么改#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0400//默认是0x0600,不通过
#endif#include "stdafx.h"
#include <windows.h>
#include <Ras.h>
#include <raserror.h>
#pragma comment(lib,"rasapi32.lib")
int _tmain(int argc, _TCHAR* argv[])
{
RASCONN rasCon[10];
rasCon[0].dwSize=sizeof(RASCONN);
DWORD dwSize;
dwSize=sizeof(RASCONN)*10;
DWORD dwConNum=0;
RasEnumConnections(rasCon,&dwSize,&dwConNum);
for(int i=0;i<dwConNum;i++)
{
DWORD dwRul=::RasHangUp(rasCon[i].hrasconn);
}
return 0;
}