Jump to content

Convert Registry Shutdown value to date/time


HeidiR
 Share

Recommended Posts

Hi All,

I'm trying to convert the Windows registry Shutdown value to a date/time string. The reg path and key are below.

RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows", "ShutdownTime")

However, I have not yet been successful iin converting the REG_BINARY value (e.g. hex:b0,ce,a6,34,68,4f,c9,01) to a date/time string.

Any ideas?

HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/
Link to comment
Share on other sites

This is a FileTime structure in binayr format. You can read it like this:

#include<Date.au3>
; Read Value
$RegVal = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows", "ShutdownTime") 
; Create a FileTime Struct (in bytes, so you can set registry value)
$FileTime = DllStructCreate("byte[" & _SIZEOF($tagFILETIME) & "]")
; set data to struct
DllStructSetData($FileTime,1,Binary("0x"&$RegVal))
; Convert to String
$String = _Date_Time_FileTimeToStr($FileTime)

MsgBox(0, '', $String)

; Prog@ndy
Func _SIZEOF($tagStruct)
    Return DllStructGetSize(DllStructCreate($tagStruct,1))
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

This is a FileTime structure in binayr format. You can read it like this:

#include<Date.au3>
; Read Value
$RegVal = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Windows", "ShutdownTime") 
; Create a FileTime Struct (in bytes, so you can set registry value)
$FileTime = DllStructCreate("byte[" & _SIZEOF($tagFILETIME) & "]")
; set data to struct
DllStructSetData($FileTime,1,Binary("0x"&$RegVal))
; Convert to String
$String = _Date_Time_FileTimeToStr($FileTime)

MsgBox(0, '', $String)

; Prog@ndy
Func _SIZEOF($tagStruct)
    Return DllStructGetSize(DllStructCreate($tagStruct,1))
EndFunc

Perfect! Many thanks for your help!

HeidiRFind free applications, code examples and more on my site at:http://heidisdownloads.com/
Link to comment
Share on other sites

  • 3 years later...

I'm actually trying to use the above code but $String always comes back as null.

I believe I'm having troubles using the _Date_Time_FileTimeToStr function as @Error returns 1. Any thoughts? I'm not much of a programmer, pretty new to this.

Link to comment
Share on other sites

  • 8 years later...
#include<Date.au3>
; Read Value
Func _filetime2str($RegVal = "6000000010000000")
; Create a FileTime Struct (in bytes, so you can set value)
$FileTime = DllStructCreate("struct; dword hi; dword lo; endstruct")
; set data to struct
;set hi value
DllStructSetData($FileTime,1,Binary("0x"&Stringleft($RegVal,8)))
;set lo value
DllStructSetData($FileTime,2,Binary("0x"&StringRight($RegVal,8))
; Convert to String
$String = _Date_Time_FileTimeToStr($FileTime)
ConsoleWrite($String&@CRLF)
return $String
EndFunc

this is what i use to convert 64bit FileTime value from registry into Readable Date/Time string

convert 64bit Filetime hex string into local time String

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...