在vb.net里 ping域名得到ip地址 怎么弄
答案:7 悬赏:70 手机版
解决时间 2021-03-31 08:33
- 提问者网友:聂風
- 2021-03-30 15:18
知道机器的的域名地址那域名所在的ip是动态的怎么实现 ping域名 把返回回来的ip地址赋值给a变量注:要源码 我用的是vb9.0的
最佳答案
- 五星知识达人网友:举杯邀酒敬孤独
- 2021-01-08 10:45
我来说说...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
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
全部回答
- 1楼网友:渡鹤影
- 2020-02-12 01:11
这就要看你自己怎么想
- 2楼网友:春色三分
- 2020-07-17 06:06
要是嫌不详送给我 我给养活着
- 3楼网友:神的生死簿
- 2019-06-29 06:46
其实这个很简单 才子你早来问我不就好了?只要如此如此 这般这般 不就行了?
- 4楼网友:轻雾山林
- 2020-05-11 12:10
亥时出生的人有好命也有歹命,一个的命好不好需要出生年月日时来决定(父母兄弟姐妹的命盘对他也有影响),命理是一门很系统的学问,单凭一个时辰是说明不了什么问题的。
- 5楼网友:爱难随人意
- 2019-05-30 22:20
迷信啊
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯