2009-02-09 36 views

回答

1

有很多選擇。

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