同上!!!

解决方案 »

  1.   

    可以使用 WNetCancelConnection 或 WNetCancelConnection2 两个API,具体的查查MSDN
    另外,你可以参考一下:
    http://www.csdn.net/magazine/expert/Topic/0/45.shtm
      

  2.   

    Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long
    Private Declare Function WNetCancelConnection Lib "mpr.dll" Alias "WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As Long
    Const WN_SUCCESS = 0 ' The function was successful.
    Const WN_NET_ERROR = 2 ' An error occurred on the network.
    Const WN_BAD_PASSWORD = 6 ' The password was invalid.
    Function AddConnection(MyShareName As String, MyPWD As String, UseLetter As String) As Integer
        On Local Error GoTo AddConnection_Err
        AddConnection = WNetAddConnection(MyShareName, MyPWD, UseLetter)
    AddConnection_End:
        Exit Function
    AddConnection_Err:
        AddConnection = Err
        MsgBox Error$
        Resume AddConnection_End
    End Function
    Function CancelConnection(DriveLetter As String, Force As Integer) As Integer
        On Local Error GoTo CancelConnection_Err
        CancelConnection = WNetCancelConnection(DriveLetter, Force)
    CancelConnection_End:
        Exit Function
    CancelConnection_Err:
        CancelConnection = Err
        MsgBox Error$
        Resume CancelConnection_End
    End Function
    Private Sub Form_Load()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]    'to add a connection call by:
        variable = AddConnection(<SharePath>, <Password>, <DriveLetter>)
        'To cancel a connection type:
        varible = CancelConnection(<SharePath, <Force>)
    End Sub
      

  3.   

    To orcale:不是吧~~~你这是用于拨号的吧????我是在局域网中用,就是把“本地连接”断开和启用,哪用的上password之类的东东呀??
      

  4.   

    你是想屏蔽一些东西吧?可以用Shell函数调用net命令来关闭某些服务,当然也可以断开网络连接。Shell "net stop server /y"
      

  5.   

    开启就用:Shell "net start server"
      

  6.   

    不成呀!用了Shell "net stop server /y",可本地连接并没断开呀!
    希望大侠能在说详细些!谢谢!
      

  7.   

    我说的断开本地连接并不是运行Shell "net stop server /y",这只是举一个例子,应该是停止别的服务,我这里没有网络环境,所以无法调试。
    你再试试停止别的某些服务。
      

  8.   

    我试了,所有服务中Network Connections最有可能了,可停止不了,刚停止马上自己就启动了!还有,/y是做什么用的?