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

📄 断开拨号连接.frm

📁 Windows API函数,希望大伙有用哦
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   1095
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4500
   LinkTopic       =   "Form1"
   ScaleHeight     =   1095
   ScaleWidth      =   4500
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "拨号连接"
      Height          =   345
      Left            =   660
      TabIndex        =   0
      Top             =   330
      Width           =   1245
   End
   Begin VB.CommandButton Command2 
      Caption         =   "断开连接"
      Height          =   345
      Left            =   2370
      TabIndex        =   1
      Top             =   330
      Width           =   1245
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'字符常数说明
Const RAS_MAXENTRYNAME As Integer = 256
Const RAS_MAXDEVICETYPE As Integer = 16
Const RAS_MAXDEVICENAME As Integer = 128
Const RAS_RASCONNSIZE As Integer = 412
Const ERROR_SUCCESS = 0&
'结构型变量说明
Private Type RasConn
  dwSize As Long
  hRasConn As Long
  szEntryName(RAS_MAXENTRYNAME) As Byte
  szDeviceType(RAS_MAXDEVICETYPE) As Byte
  szDeviceName(RAS_MAXDEVICENAME) As Byte
End Type
'API函数声明
Private Declare Function InternetAttemptConnect Lib "wininet" (ByVal dwReserved As Long) As Long
Private Declare Function RasEnumConnections Lib "rasapi32.dll" Alias "RasEnumConnectionsA" (lpRasConn As Any, lpcb As Long, lpcConnections As Long) As Long
Private Declare Function RasHangUp Lib "rasapi32.dll" Alias "RasHangUpA" (ByVal hRasConn As Long) As Long
Private gstrISPName As String
Private ReturnCode As Long
Private Sub Command1_Click()
  If InternetAttemptConnect(ByVal 0&) = 0 Then
        MsgBox "您已经连接 Internet   ", vbInformation
     Else
        MsgBox "您没能连接 Internet   ", vbInformation
   End If
End Sub
Private Sub Command2_Click()
  Dim i As Long, lpRasConn(255) As RasConn, lpcb As Long
  Dim lpcConnections As Long, hRasConn As Long
  lpRasConn(0).dwSize = RAS_RASCONNSIZE
  lpcb = RAS_MAXENTRYNAME * lpRasConn(0).dwSize
  lpcConnections = 0
  ReturnCode = RasEnumConnections(lpRasConn(0), lpcb, lpcConnections)
  If ReturnCode = 0 Then
     For i = 0 To lpcConnections - 1
        hRasConn = lpRasConn(i).hRasConn
        ReturnCode = RasHangUp(ByVal hRasConn)
      Next i
  End If
  Unload Me
  End
End Sub















⌨️ 快捷键说明

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