怎样用VB编出控制网络通断的程序?用哪个API函数啊?

解决方案 »

  1.   

    用这个函数.
    Private Declare Function RasHangUp Lib "rasapi32.dll" Alias "RasHangUpA" (ByVal hRasConn As Long) As Long
      

  2.   

    ' 摘自MSDNRasHangUp
    The RasHangUp function terminates a remote access connection. The connection is specified with a RAS connection handle. The function releases all RASAPI32.DLL resources associated with the handle. DWORD RasHangUp(
      HRASCONN hrasconn   // handle to the RAS connection to hang up
    );
     
    Parameters
    hrasconn 
    Identifies the remote access connection to terminate. This is a handle returned from a previous call to RasDial or RasEnumConnections. 
    Return Values
    If the function succeeds, the return value is zero.If the function fails, the return value is a nonzero error value listed in the RAS header file, or ERROR_INVALID_HANDLE. Res
    The connection is terminated even if the RasDial call has not yet been completed. After this call, the hrasconn handle can no longer be used. An application should not call RasHangUp and then immediately exit. The connection state machine needs time to properly terminate. If the system prematurely terminates the state machine, the state machine may fail to properly close a port, leaving the port in an inconsistent state. A simple way to avoid this problem is to call Sleep(3000) after returning from RasHangUp; after that pause, the application can exit. A more responsive way to avoid the problem is, after returning from RasHangUp, to call RasGetConnectStatus(hrasconn) and Sleep(0) in a loop until RasGetConnectStatus returns ERROR_INVALID_HANDLE. QuickInfo
      Windows NT: Requires version 3.1 or later.
      Windows: Requires Windows 95 or later.
      Windows CE: Requires version 1.0 or later.
      Header: Declared in ras.h.
      Import Library: Use rasapi32.lib.
      Unicode: Implemented as Unicode and ANSI versions on Windows NT.See Also
    Remote Access Service Overview, RAS Server Administration Functions, RASCONN, RasDial, RasEnumConnections, RasGetConnectStatus,Sleep