HeidiR Posted November 26, 2008 Share Posted November 26, 2008 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 More sharing options...
ProgAndy Posted November 26, 2008 Share Posted November 26, 2008 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 More sharing options...
Bert Posted November 26, 2008 Share Posted November 26, 2008 http://www.autoitscript.com/forum/index.ph...ead++REG_BINARY The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
HeidiR Posted November 26, 2008 Author Share Posted November 26, 2008 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 More sharing options...
meltman Posted November 1, 2012 Share Posted November 1, 2012 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 More sharing options...
holyeyed Posted April 28, 2021 Share Posted April 28, 2021 #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 argumentum 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now