⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0503006.htm

📁 VC知识库5_chm_decompile_20040520_210715
💻 HTM
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
<link rel="stylesheet" type="text/css" href="../../vckbase.css">
</head>

<body>

<div align="justify">
  <table border="0" width="100%" class="font" height="57">
    <tr>
      <td width="27%" height="6" class="bigfont" bgcolor="#B8CFE7" align="center" bordercolor="#800080">
      <font color="#800080">VC知识库(五)</font>
      </td>
      <td width="73%" height="6" class="bigfont" bgcolor="#B8CFE7" align="center" bordercolor="#800080">
      <font color="#800080">www.vckbase.com</font>
      </td>
    </tr>
    <tr>
      <td width="100%" height="4" class="header" valign="top" align="center" colspan="2">
      <hr>
      </td>
    </tr>
    <tr>
      <td width="100%" height="17" class="header" valign="top" align="center" colspan="2">
      <big><strong>在使用Internet后挂断线路</strong></big></NOSCRIPT>
      </td>
    </tr>
    <tr>
      <td width="100%" height="17" class="info" align="center" colspan="2">
      </td>  
    </tr>  
    <tr> 
      <td width="100%" height="22" class="font" colspan="2">
        <hr>
      </td>  
    </tr> 
    <tr> 
      <td width="100%" height="5" class="font" colspan="2"> 



<p>WinInet API提供的功能很强大,但是当关闭掉Internet事务却不能关闭掉dial  
 
up连接。在WinInet API中没有提供相应的函数完成该功能。</p> 
 
 
 
<h3>解决方法:</h3> 
 
 
 
<p>RAS API可以通过调用RasHangUp(...)关闭连接,但是需要RAS句柄。有两种方法可以得当RAS句柄:1、自己建立RAS连接是保存该句柄,但这样做对与解决当前提出的问题是没必要的,2、通过RasEnumConnections(...)列举所有句柄。</p> 
 
 
 
<h3>所需环境:</h3> 
 
 
 
<ol> 
 
  <li>RASAPI32.DLL,该连接库在安装播号网络时会自动安装。</li> 
 
  <li>RAS.H </li> 
 
  <li>RASAPI32.LIB </li> 
 
</ol> 
 
 
 
<h3>示范代码:<!-- start a block of source code --></h3> 
 
<!-- start a block of source code --> 
 
 
 
<p><tt><font color="#990000">// Quit a dial up connection&nbsp; - rasapi32.lib und  
 
#include &quot;ras.h&quot; needed<br> 
 
bool DisconnectRas()<br> 
 
{<br> 
 
&nbsp;&nbsp; bool bOk = false;<br> 
 
&nbsp;&nbsp; RASCONN ras[20];<br> 
 
&nbsp;&nbsp; DWORD dSize,dNumber,dCount;<br> 
 
<br> 
 
&nbsp;&nbsp; ras[0].dwSize = sizeof(RASCONN);<br> 
 
&nbsp;&nbsp; dSize = sizeof( ras );<br> 
 
<br> 
 
&nbsp;&nbsp; // Get active RAS - Connection<br> 
 
&nbsp;&nbsp; if( RasEnumConnections( ras, &amp;dSize, &amp;dNumber ) == 0 )<br> 
 
&nbsp;&nbsp; {<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bOk = true;<br> 
 
<br> 
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for( dCount = 0; dCount &lt; dNumber; dCount++ )<br> 
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Hang up that connection<br> 
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( RasHangUp(ras[dCount].hrasconn) != 0  
 
)<br> 
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bOk = false;<br> 
 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>

&nbsp;&nbsp; }<br>

&nbsp;&nbsp; return bOk;<br> 
 
}</font></tt></p> 
 
      </td>     
    </tr>    
    <tr> 
      <td width="100%" height="12" class="font" colspan="2">  
      </td>     
    </tr> 
    <tr> 
      <td width="100%" height="6" class="font" colspan="2">  
      </td>     
    </tr> 
    <tr> 
      <td width="100%" height="8" class="font" colspan="2">  
      </td>     
    </tr> 
    <tr>    
      <td width="100%" height="17" class="font" colspan="2"></td>     
    </tr>    
  </table>     
</div>     
     
</body>     
     
</html>     

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -