0

我写了这个例程:

Public Function LipPCIsOn() As String
  '  Return TimeSpan.FromMilliseconds(System.Environment.TickCount).ToString()
  Dim query As New SelectQuery("SELECT LastBootUpTime FROM Win32_OperatingSystem WHERE Primary='true'")
  Dim searcher = New ManagementObjectSearcher(query)

  Dim ret As String = ""
  Dim mo As ManagementObject
  For Each mo In searcher.Get()
     Dim dtBootTime As DateTime = ManagementDateTimeConverter.ToDateTime(mo.Properties("LastBootUpTime").Value.ToString())
     ret = (Now - dtBootTime).ToString()
  Next

  Return ret
End Function

但我有这个错误:

SelectQuery is not defined
ManagementObjectSearcher is not defined
ManagementObject is not defined

我有这些导入集:

Imports System
Imports System.Management
Imports System.Security
Imports System.IO
Imports System.IO.File
Imports System.IO.FileStream
Imports System.Windows.Forms

还有什么需要的吗?谢谢

4

0 回答 0