當前位置:編程學習大全網 - 源碼下載 - 在vb.net裏 ping域名得到ip地址 怎麽弄

在vb.net裏 ping域名得到ip地址 怎麽弄

我來說說...i試試看行不行。Option Explicit

Const SYNCHRONIZE = &H100000

Const INFINITE = &HFFFF

Const WAIT_OBJECT_0 = 0

Const WAIT_TIMEOUT = &H102

Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Sub cmdClear_Click()

txtIP.Text = ""

txtNumber.Text = ""

Open "C:\log.txt" For Output As #1

Close #1

txtOutPut.Text = ""

End Sub

Private Sub cmdPing_Click()

Dim ShellX As String

Dim lPid As Long

Dim lHnd As Long

Dim lRet As Long

Dim VarX As String

frmMain.MousePointer = 11

If txtIP.Text <> "" Then

DoEvents

ShellX = Shell("command.com /c ping -n " & txtNumber.Text & " " & txtIP.Text & " > C:\log.txt", vbHide)

lPid = ShellX

If lPid <> 0 Then

lHnd = OpenProcess(SYNCHRONIZE, 0, lPid)

If lHnd <> 0 Then

lRet = WaitForSingleObject(lHnd, INFINITE)

CloseHandle (lHnd)

End If

Beep

frmMain.MousePointer = 0

Open "C:\log.txt" For Input As #1

txtOutPut.Text = Input(LOF(1), 1)

Close #1

End If

Else

frmMain.MousePointer = 0

VarX = MsgBox("You have not entered an ip address or the number of times you want to ping.", vbCritical, "Error has occured")

End If

End Sub

  • 上一篇:壹個PHP文章發布系統
  • 下一篇:手機股票日k線的正確觀察方法
  • copyright 2024編程學習大全網