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

📄 form1.frm

📁 网络拨号列表查询
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "获取网卡的物理地址"
   ClientHeight    =   2145
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5340
   LinkTopic       =   "Form1"
   ScaleHeight     =   2145
   ScaleWidth      =   5340
   StartUpPosition =   1  '所有者中心
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   375
      Left            =   2700
      TabIndex        =   3
      Top             =   1350
      Width           =   1095
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   1170
      TabIndex        =   1
      Top             =   690
      Width           =   3135
   End
   Begin VB.CommandButton Command1 
      Caption         =   "获取"
      Height          =   375
      Left            =   1485
      TabIndex        =   0
      Top             =   1350
      Width           =   1095
   End
   Begin VB.Label Label1 
      Caption         =   "物理地址:"
      Height          =   285
      Left            =   1245
      TabIndex        =   2
      Top             =   375
      Width           =   1305
   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 NCBASTAT As Long = &H33
 Const NCBNAMSZ As Long = 16
 Const HEAP_ZERO_MEMORY As Long = &H8
 Const HEAP_GENERATE_EXCEPTIONS As Long = &H4
 Const NCBRESET As Long = &H32
 
Private Type NET_CONTROL_BLOCK
  ncb_command    As Byte
  ncb_buffer     As Long
  ncb_length     As Integer
  ncb_callname   As String * NCBNAMSZ
  ncb_name       As String * NCBNAMSZ
  ncb_lana_num   As Byte
  ncb_cmd_cplt   As Byte
End Type

Private Type ADAPTER_STATUS
  adapter_address(5) As Byte
  adapter_type      As Byte
End Type
   
Private Type NAME_BUFFER
  name        As String * NCBNAMSZ
  name_num    As Integer
  name_flags  As Integer
End Type

Private Type ASTAT
  adapt          As ADAPTER_STATUS
  NameBuff(30)   As NAME_BUFFER
End Type

Private Declare Function Netbios Lib "netapi32.dll" (pncb As NET_CONTROL_BLOCK) As Byte

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, _
    ByVal hpvSource As Long, ByVal cbCopy As Long)

Private Declare Function GetProcessHeap Lib "kernel32" () As Long

Private Declare Function HeapAlloc Lib "kernel32" (ByVal hHeap As Long, _
    ByVal dwFlags As Long, ByVal dwBytes As Long) As Long
    
Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, _
    ByVal dwFlags As Long, lpMem As Any) As Long


Private Sub Command1_Click()
  Dim i As Integer
  Dim pASTAT As Long
  Dim NCB As NET_CONTROL_BLOCK
  Dim AST As ASTAT
  
  NCB.ncb_command = NCBRESET
  Call Netbios(NCB)
  NCB.ncb_callname = "*               "
  NCB.ncb_command = NCBASTAT
  NCB.ncb_lana_num = 0
  NCB.ncb_length = Len(AST)
  pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS _
          Or HEAP_ZERO_MEMORY, NCB.ncb_length)
  NCB.ncb_buffer = pASTAT
  Call Netbios(NCB)
  CopyMemory AST, NCB.ncb_buffer, Len(AST)
  For i = 0 To 5
      Text1.Text = Text1.Text & Format$(Hex(AST.adapt.adapter_address(i)), "00") & "  "
  Next i
  HeapFree GetProcessHeap(), 0, pASTAT
End Sub

Private Sub Command2_Click()
  End
End Sub

⌨️ 快捷键说明

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