0

I write this routine:

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

But i have this error:

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

I have these Imports set:

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

Is there anything else needed? Thank you

Antony
  • 83
  • 11

0 Answers0