2009-06-11 47 views

回答

2

另一种方法是使用.NET中的性能计数器。

Dim pc As PerformanceCounter = New PerformanceCounter("System", "System Up Time") 

pc.NextValue() ' This returns zero for a reason I don't know 

' This call to NextValue gets the correct value 
Dim ts As TimeSpan = TimeSpan.FromSeconds(pc.NextValue()) 

所以基本上,PerformanceCounter类将返回系统启动的秒数,从那里你可以做你想做的事情。

+0

谢谢,这对我有用。至于这里别人一提的是转换后的VB代码我使用: 昏暗uptimeTs作为新的时间跨度() 昏暗的PC作为新的PerformanceCounter(“系统”,“系统运行时间”) pc.NextValue() uptimeTs = TimeSpan.FromSeconds(pc.NextValue()) – Brian 2009-06-11 12:45:26

0

如果启用了SNMP,则可以查询以下OID:1.3.6.1.2.1.1.3.0。这将为您提供系统正常运行时间。它被定义为“自从系统的网络管理部分最后重新初始化以来的时间(以百分之一秒为单位)”。

相关问题