title: Using System.Management Object
body: <p>I write this routine:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>But i have this error: </p>
  
  <pre><code>SelectQuery is not defined
  ManagementObjectSearcher is not defined
  ManagementObject is not defined
  </code></pre>
  
  <p>I have these Imports set:</p>
  
  <pre><code>Imports System
  Imports System.Management
  Imports System.Security
  Imports System.IO
  Imports System.IO.File
  Imports System.IO.FileStream
  Imports System.Windows.Forms
  </code></pre>
  
  <p>Is there anything else needed?
  Thank you</p>