?? form1.frm
字號:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 1800
TabIndex = 0
Top = 1320
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Function EthernetAddress() As String '使用WMI取網卡號,win2000和XP下用
On Error GoTo ErrorHandle
Dim objs, obj
Set objs = GetObject("winmgmts:").ExecQuery("SELECT MACAddress " & _
"FROM Win32_NetworkAdapter WHERE " & _
"((MACAddress Is Not NULL) AND (Manufacturer <> 'Microsoft'))")
For Each obj In objs '有多個網卡,只取一個
EthernetAddress = obj.MACAddress
Exit For
Next
'取回來的格式為 00:00:00:00:00,去掉中間的:
EthernetAddress = Replace(EthernetAddress, ":", "-")
Exit Function
ErrorHandle:
' MsgBox "取網卡號錯誤,系統不能正常使用,請檢查您的電腦硬件設備!" & Chr(13) & "請查看“服務”中WMI服務項是否有打開!", vbCritical, "幫助信息"
End Function
Private Sub Command1_Click()
MsgBox EthernetAddress
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -