vb如何读 cmd 里 ipconfig /all生成的txt里的mac和describe?

2020-06-12 社会 104阅读
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Dim Description As String
Dim Mac As String
Shell "cmd.exe /c ipconfig /all >""" & App.Path & "\temp.tmp" & """", vbHide
Do Until Dir(App.Path & "\temp.tmp") <> ""
DoEvents
Loop
Sleep 1000
Open App.Path & "\temp.tmp" For Input As #1
Do While Not EOF(1)
Line Input #1, a
If Left(a, Len(" Description . . . . . . . . . . . :")) = " Description . . . . . . . . . . . :" Then
Description = Right(a, Len(a) - Len(" Description . . . . . . . . . . . :"))
End If
If Left(a, Len(" Physical Address. . . . . . . . . :")) = " Physical Address. . . . . . . . . :" Then
Mac = Right(a, Len(a) - Len(" Physical Address. . . . . . . . . :"))
End If
Loop
Close #1
Kill App.Path & "\temp.tmp"
MsgBox "Description:" & Description
MsgBox "Mac:" & Mac
End Sub
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com