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

📄 frmselectnic.frm

📁 设置IP地址工具
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmSelectNIC 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "网卡选择"
   ClientHeight    =   4200
   ClientLeft      =   3540
   ClientTop       =   4245
   ClientWidth     =   6210
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4200
   ScaleWidth      =   6210
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmdSave 
      Caption         =   "激活"
      Default         =   -1  'True
      Height          =   345
      Left            =   3420
      TabIndex        =   1
      Top             =   3420
      Width           =   1245
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "取消"
      Height          =   345
      Left            =   4800
      TabIndex        =   2
      Top             =   3420
      Width           =   1245
   End
   Begin VB.ListBox lstNIC 
      Height          =   2985
      Left            =   120
      TabIndex        =   0
      Top             =   330
      Width           =   5955
   End
   Begin VB.Label lblStatus 
      BorderStyle     =   1  'Fixed Single
      Height          =   285
      Left            =   0
      TabIndex        =   4
      Top             =   3900
      Width           =   6195
   End
   Begin VB.Label lblNIC 
      AutoSize        =   -1  'True
      Caption         =   "选择激活网卡"
      Height          =   195
      Left            =   120
      TabIndex        =   3
      Top             =   90
      Width           =   1080
   End
End
Attribute VB_Name = "frmSelectNIC"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim pSelectedNIC As String

Private Sub cmdCancel_Click()
  pSelectedNIC = ""
  Unload Me
End Sub

Private Sub cmdSave_Click()
    Dim sMsg As String
    
    If lstNIC.ListIndex <> -1 Then
        pSelectedNIC = lstNIC.Text
    End If
    Unload Me
End Sub

Private Sub Form_Load()
    Dim i As Integer
    
    '获得网卡信息
    RetrieveLstNIC
    
End Sub

Private Sub RetrieveLstNIC()
    Dim strComputer As String
    Dim objWMIService As Object
    Dim colItems As Object
    Dim objItem As Object
    Dim NICDescription As String
    Dim pos As Integer

    On Error Resume Next
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMIService.ExecQuery( _
        "SELECT * FROM Win32_NetworkAdapterConfiguration where IPEnabled=TRUE", , 48)
        
    For Each objItem In colItems
        pos = InStr(1, objItem.Caption, "] ")
   
        If pos Then
            NICDescription = Mid$(objItem.Caption, pos + 2)
        End If
        lstNIC.AddItem NICDescription
    Next
    
    Set objItem = Nothing
    Set colItems = Nothing
    Set objWMIService = Nothing
End Sub


Public Property Get SelectedNIC() As String
    SelectedNIC = pSelectedNIC
End Property

Private Sub lstNIC_DblClick()
    Call cmdSave_Click
End Sub

⌨️ 快捷键说明

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