maidinhdan > 25-04-16, 11:10 AM
Public Function KiemtraIP(IPcankiemtra As String)
Dim strCommand As String
Dim strPing As String
strCommand = "%ComSpec% /C %SystemRoot%\system32\ping.exe -n 1 -w 500 " & IPcankiemtra & " | " & "%SystemRoot%\system32\find.exe /i " & Chr(34) & "TTL=" & Chr(34)
strPing = fShellRun(strCommand)
If strPing = "" Then
KiemtraIP = "Tat"
Else
KiemtraIP = "Mo"
End If
End Function
Function fShellRun(sCommandStringToExecute)
Dim oShellObject, oFileSystemObject, sShellRndTmpFile
Dim oShellOutputFileToRead, iErr
Set oShellObject = CreateObject("Wscript.Shell")
Set oFileSystemObject = CreateObject("Scripting.FileSystemObject")
sShellRndTmpFile = oShellObject.ExpandEnvironmentStrings("%temp%") & oFileSystemObject.GetTempName
On Error Resume Next
oShellObject.Run sCommandStringToExecute & " > " & sShellRndTmpFile, 0, True
iErr = Err.Number
On Error GoTo 0
If iErr <> 0 Then
fShellRun = ""
Exit Function
.................................................................................. dài quá xóa bớt
End Function
Private Sub cmdTest_Click()
If KiemtraIP(Me.txtIP) = "Mo" Then
MsgBox "(On) May co IP: [" & Me.txtIP & "] dang Mo.", vbInformation, "Thong bao"
Else
MsgBox "(Off) May co IP: " & Me.txtIP & " dang Tat hoac khong ton tai.", vbInformation, "Thong bao"
End If
End Sub
kieu manh > 26-04-16, 11:16 AM
Minh Tiên > 26-04-16, 05:45 PM
nguyenhungcuong > 04-06-16, 02:49 PM
mrsiro > 28-01-18, 12:23 PM
zinzin8x > 01-02-18, 11:46 AM