IFIX上位机添加IP测试
效果
实现画面
实现脚本
Option Explicit
Private Declare Function GetExitCodeProcess Lib "kernel32" ( _
ByVal hProcess As Long, _
lpExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" ( _
ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" ( _
ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Const PROCESS_QUERY_INFORMATION = &H400
Const STILL_ALIVE = &H103
Private Sub Text2_Click()
Dim pid As Long
pid = Shell("cmd.exe /C Ping " & "192.168.0.135" & " > c:\ipaac.txt", vbHide)
Dim hProc As Long
hProc = OpenProcess(PROCESS_QUERY_INFORMATION, 0, pid)
Dim ExitCode As Long
Do
Call GetExitCodeProcess(hProc, ExitCode)
DoEvents
Loop While ExitCode = STILL_ALIVE
Text3.Caption = ""
Open "c:\ipaac.txt" For Input As #1
Dim strLine As String
Do Until EOF(1)
Line Input #1, strLine
Text3.Caption = Text3.Caption & strLine & vbNewLine
Loop
Close #1
On Error Resume Next
Kill "c:\ipaac.txt"
On Error GoTo 0
End Sub