vb.net中ping的简单介绍

在vb.net里 ping域名得到ip地址 怎么弄我来说说...i试试看行不行 。OptionExplicit
ConstSYNCHRONIZE=H100000
ConstINFINITE=HFFFF
ConstWAIT_OBJECT_0=0
ConstWAIT_TIMEOUT=H102
PrivateDeclareFunctionSendMessageLib"User32"Alias"SendMessageA"(ByValhWndAsLong,ByValwMsgAsLong,ByValwParamAsLong,lParamAsAny)AsLong
PrivateDeclareFunctionOpenProcessLib"kernel32"(ByValdwDesiredAccessAsLong,ByValbInheritHandleAsLong,ByValdwProcessIdAsLong)AsLong
PrivateDeclareFunctionWaitForSingleObjectLib"kernel32"(ByValhHandleAsLong,ByValdwMillisecondsAsLong)AsLong
PrivateDeclareFunctionCloseHandleLib"kernel32"(ByValhObjectAsLong)AsLong
PrivateSubcmdClear_Click()
txtIP.Text=""
txtNumber.Text=""
Open"C:\log.txt"ForOutputAs#1
Close#1
txtOutPut.Text=""
EndSub
PrivateSubcmdPing_Click()
DimShellXAsString
DimlPidAsLong
DimlHndAsLong
DimlRetAsLong
DimVarXAsString
frmMain.MousePointer=11
IftxtIP.Text""Then
DoEvents
ShellX=Shell("command.com/cping-n"txtNumber.Text""txtIP.Text"C:\log.txt",vbHide)
lPid=ShellX
IflPid0Then
lHnd=OpenProcess(SYNCHRONIZE,0,lPid)
IflHnd0Then
lRet=WaitForSingleObject(lHnd,INFINITE)
CloseHandle(lHnd)
EndIf
Beep
frmMain.MousePointer=0
Open"C:\log.txt"ForInputAs#1
txtOutPut.Text=Input(LOF(1),1)
Close#1
EndIf
Else
frmMain.MousePointer=0
VarX=MsgBox("Youhavenotenteredanipaddressorthenumberoftimesyouwanttoping.",vbCritical,"Errorhasoccured")
EndIf
EndSub
vb.net 怎么把ping写成一个dllvb.net中ping你是说你要测试网络.但是想写成DLL文件调用吗
那玩意叫类库.你在创建vb.net中ping的时候创建个类库就可以vb.net中ping了.然后新建一个类.调用相关函数就可以vb.net中ping了
怎样在VB.net中获得ping命令的结果首先添加一模块 , 代码如下
Option Explicit
Private Const IP_SUCCESS As Long = 0
Private Const IP_STATUS_BASE As Long = 11000
Private Const IP_BUF_TOO_SMALL As Long = (11000 + 1)
Private Const IP_DEST_NET_UNREACHABLE As Long = (11000 + 2)
Private Const IP_DEST_HOST_UNREACHABLE As Long = (11000 + 3)
Private Const IP_DEST_PROT_UNREACHABLE As Long = (11000 + 4)
Private Const IP_DEST_PORT_UNREACHABLE As Long = (11000 + 5)
Private Const IP_NO_RESOURCES As Long = (11000 + 6)
Private Const IP_BAD_OPTION As Long = (11000 + 7)
Private Const IP_HW_ERROR As Long = (11000 + 8)
Private Const IP_PACKET_TOO_BIG As Long = (11000 + 9)
Private Const IP_REQ_TIMED_OUT As Long = (11000 + 10)
Private Const IP_BAD_REQ As Long = (11000 + 11)
Private Const IP_BAD_ROUTE As Long = (11000 + 12)
Private Const IP_TTL_EXPIRED_TRANSIT As Long = (11000 + 13)
Private Const IP_TTL_EXPIRED_REASSEM As Long = (11000 + 14)
Private Const IP_PARAM_PROBLEM As Long = (11000 + 15)
Private Const IP_SOURCE_QUENCH As Long = (11000 + 16)
Private Const IP_OPTION_TOO_BIG As Long = (11000 + 17)
Private Const IP_BAD_DESTINATION As Long = (11000 + 18)
Private Const IP_ADDR_DELETED As Long = (11000 + 19)
Private Const IP_SPEC_MTU_CHANGE As Long = (11000 + 20)
Private Const IP_MTU_CHANGE As Long = (11000 + 21)
Private Const IP_UNLOAD As Long = (11000 + 22)
Private Const IP_ADDR_ADDED As Long = (11000 + 23)
Private Const IP_GENERAL_FAILURE As Long = (11000 + 50)
Private Const MAX_IP_STATUS As Long = (11000 + 50)
Private Const IP_PENDING As Long = (11000 + 255)
Private Const PING_TIMEOUT As Long = 500
Private Const WS_VERSION_REQD As Long = H101
Private Const MIN_SOCKETS_REQD As Long = 1
Private Const SOCKET_ERROR As Long = -1
Private Const INADDR_NONE As Long = HFFFFFFFF
Private Const MAX_WSADescription As Long = 256
Private Const MAX_WSASYSStatus As Long = 128

推荐阅读