Free Hit Counters

Monday, January 3, 2011

Windows Installation DateTime


Get Windows Installation DateTime
Public Shared Function GetWindowsInstallationDateTime(computerName as String) as DateTime
 Dim key as Microsoft.Win32.RegistryKey
 key = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, computerName)
 key = key.OpenSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion", False)
 If key IsNot Nothing Then
  Dim startDate as DateTime
  Dim regVal as Int64 
  startDate = new DateTime(1970, 1, 1, 0, 0, 0)
  regVal = Convert.ToInt64(key.GetValue("InstallDate").ToString()) 
  Return startDate.AddSeconds(regVal)
 End If 
 Return DateTime.MinValue
End Function  

No comments:

Post a Comment

Free Hit Counters