0
我知道Environment.TickCount存在,但我有一個很大的問題,它只限於25天。正確的函數來查找自Windows啓動以來流逝的時間?
什麼將是一個很好的選擇,不需要外部模塊/ DLL,並將工作在Windows Server 2003的香草安裝?
謝謝
我知道Environment.TickCount存在,但我有一個很大的問題,它只限於25天。正確的函數來查找自Windows啓動以來流逝的時間?
什麼將是一個很好的選擇,不需要外部模塊/ DLL,並將工作在Windows Server 2003的香草安裝?
謝謝
有很多選擇。
public TimeSpan SystemUpTime()
{
PerformanceCounter upTime =
new PerformanceCounter("System", "System Up Time");
// You've got to call this twice. First time it returns 0
// and the second time it returns the real info.
upTime.NextValue();
return TimeSpan.FromSeconds(upTime.NextValue());
}
但是,如果您沒有足夠的權限,則不會運行。
您還可以使用WMI
您可以使用WMI
得到WIN32_OperatingSystem.LastBootUpTime
。