以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请问可以用Network.Ping 返回反馈的时间吗?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=84135)

--  作者:Hyphen
--  发布时间:2016/4/23 17:24:00
--  
如果是数据库服务器,通过sql访问数据库取得服务器时间,比如:select GetDate()

否则只能通过在服务器架设网站或者web服务来取时间了

--  作者:大红袍
--  发布时间:2016/4/24 13:34:00
--  

mark 获取ping时间

 

Dim p As new Process()
p.StartInfo.FileName = "cmd.exe"
p.StartInfo.UseShellExecute = False \'关闭Shell的使用
p.StartInfo.RedirectStandardInput = True \'重定向标准输入
p.StartInfo.RedirectStandardOutput = True \'重定向标准输出
p.StartInfo.RedirectStandardError = True \'重定向错误输出
p.StartInfo.CreateNoWindow = True \'设置不显示窗口
p.Start()
p.StandardInput.WriteLine("ping www.baidu.com")
p.StandardInput.WriteLine("exit")

Dim str As String = p.StandardOutput.ReadToEnd()
msgbox(str)


Dim mc = System.Text.RegularExpressions.Regex.Matches(str, "(?<=平均 = )[0-9]+")
If mc.count = 0 Then
    msgbox("连不上")
Else
    msgbox(mc(0).value)
end if