📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "网络连接是否可用"
ClientHeight = 2745
ClientLeft = 45
ClientTop = 330
ClientWidth = 4635
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2745
ScaleWidth = 4635
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text5
Height = 270
Left = 1680
TabIndex = 10
Text = "Text5"
Top = 1800
Width = 2655
End
Begin VB.TextBox Text4
Height = 270
Left = 1680
TabIndex = 9
Text = "Text4"
Top = 1440
Width = 1215
End
Begin VB.TextBox Text3
Height = 270
Left = 1680
TabIndex = 8
Text = "Text3"
Top = 1080
Width = 1215
End
Begin VB.TextBox Text2
Height = 270
Left = 1680
TabIndex = 7
Text = "Text2"
Top = 720
Width = 1215
End
Begin VB.TextBox Text1
Height = 270
Left = 1680
TabIndex = 6
Text = "Text1"
Top = 360
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "运行(&R)"
Height = 375
Left = 1800
TabIndex = 0
Top = 2280
Width = 1215
End
Begin VB.Label Label5
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "连接类型"
Height = 180
Left = 480
TabIndex = 5
Top = 1845
Width = 720
End
Begin VB.Label Label4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "连接是否可用"
Height = 180
Left = 480
TabIndex = 4
Top = 1485
Width = 1080
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "AOL连接"
Height = 180
Left = 480
TabIndex = 3
Top = 1125
Width = 630
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "RAS连接"
Height = 180
Left = 480
TabIndex = 2
Top = 765
Width = 630
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "LAN连接"
Height = 180
Left = 480
TabIndex = 1
Top = 405
Width = 630
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
If IsNetConnectionAlive() Then
Text1.Text = "可用"
Else
Text1.Text = "不可用"
End If
If IsNetConnectionLAN() Then
Text3.Text = "可用"
Else
Text3.Text = "不可用"
End If
If IsNetConnectionRAS() Then
Text4.Text = "可用"
Else
Text4.Text = "不可用"
End If
If IsNetConnectionAOL() Then
Text2.Text = "可用"
Else
Text2.Text = "不可用"
End If
Text5.Text = GetNetConnectionType()
End Sub
Private Function IsNetConnectionAlive() As Boolean
Dim tmp As Long
IsNetConnectionAlive = IsNetworkAlive(tmp) = 1
End Function
Private Function IsNetConnectionLAN() As Boolean
Dim tmp As Long
If IsNetworkAlive(tmp) = 1 Then
IsNetConnectionLAN = tmp = NETWORK_ALIVE_LAN
End If
End Function
Private Function IsNetConnectionRAS() As Boolean
Dim tmp As Long
If IsNetworkAlive(tmp) = 1 Then
IsNetConnectionRAS = tmp = NETWORK_ALIVE_WAN
End If
End Function
Private Function IsNetConnectionAOL() As Boolean
Dim tmp As Long
If IsNetworkAlive(tmp) = 1 Then
IsNetConnectionAOL = tmp = NETWORK_ALIVE_AOL
End If
End Function
Private Function GetNetConnectionType() As String
Dim tmp As Long
If IsNetworkAlive(tmp) = 1 Then
Select Case tmp
Case NETWORK_ALIVE_LAN:
GetNetConnectionType = "系统有一个或多个LAN网卡"
Case NETWORK_ALIVE_WAN:
GetNetConnectionType = "系统有一个或多个RAS连接"
Case NETWORK_ALIVE_AOL:
GetNetConnectionType = "系统已连接上美国在线"
Case Else:
End Select
Else
GetNetConnectionType = "系统无连接或发生错误"
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -