Sign in to follow this  
Followers 0
HeidiR

Convert Registry Shutdown value to date/time

5 posts in this topic

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/

Share this post


Link to post
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

Share this post


Link to post
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/

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0