2009-06-11 33 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。這將爲您提供系統正常運行時間。它被定義爲「自從系統的網絡管理部分最後重新初始化以來的時間(以百分之一秒爲單位)」。

相關問題