如何调用API来断开网络连接(专家快来看啊!)

自由唐衡 2001-07-20 12:34:04
我想做一个应用程序来实现自动断开网络连接,我家用的是猫来拨号上网。
...全文
286 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
masterz 2001-07-20
  • 打赏
  • 举报
回复
Needed:
In order to get the code below going it is necessary to

have RAS installed on the system ( RASAPI32.DLL ). This is automatically the case when you`ve got a dial up network installed
inlude RAS.H
link RASAPI32.LIB

Source Code:

// Quit a dial up connection - rasapi32.lib und #include "ras.h" needed
bool DisconnectRas()
{
bool bOk = false;
RASCONN ras[20];
DWORD dSize,dNumber,dCount;

ras[0].dwSize = sizeof(RASCONN);
dSize = sizeof( ras );

// Get active RAS - Connection
if( RasEnumConnections( ras, &dSize, &dNumber ) == 0 )
{
bOk = true;

for( dCount = 0; dCount < dNumber; dCount++ )
{
// Hang up that connection
if( RasHangUp(ras[dCount].hrasconn) != 0 )
{
bOk = false;
break;
}
}
}
return bOk;
}

azuo_lee 2001-07-20
  • 打赏
  • 举报
回复
做个后台程序,检查时间,到了预定的时间就调用InternetHangUp或InternetAutodialHangup。
qin_wei 2001-07-20
  • 打赏
  • 举报
回复
我正吃饭呢!

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧