Could anybody can help to make some VBScript to get and convert the regbinary value "lastUpdated" of sensors to some clear for human format of date? Had tried any functions but didn't get result.

Please...

Moderator: Telldus
Code: Select all
x = ReadHexDataRegValues("HKCU", "Software\Telldus\TelldusCenter\com.telldus.sensors\sensors\2\values\values\0\values\lastUpdated")
Debug.Write x
const HKEY_CURRENT_USER = &H80000001
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
oReg.GetBinaryValue HKEY_CURRENT_USER, "Software\Telldus\TelldusCenter\com.telldus.sensors\sensors\2\values\values\0\values", "lastUpdated", strRetVal
WScript.Echo vbcrlf & RegBinaryToString(strRetVal)
WScript.Echo vbcrlf & CDate(x/(86400 + 25569))
function RegBinaryToString(arrValue)
output=""
strInfo=""
for i=0 to ubound(arrValue)
if arrValue(i)<>0 then strInfo=strInfo & chr(arrValue(i))
next
RegBinaryToString=strInfo
end function
function ReadHexDataRegValues (RegRoot, RegValue)
Dim WshShell
Set WshShell = WScript.CreateObject("Wscript.Shell")
CurrentValue = WSHShell.RegRead(RegRoot & "\" & RegValue)
For I = LBound(CurrentValue) To UBound(CurrentValue)
tmphex = CStr(Hex(CurrentValue(I)))
if Len(tmphex)=1 then tmphex = "0" & tmphex
hexstr = tmphex & hexstr
Next
' While Len(hexstr) <16
' hexstr = "0" & hexstr
' Wend
ReadHexDataRegValues = HexDateToDate(hexstr)
End Function
Function HexDateToDate(hDate)
highPart = CDbl("&h" & Left(hDate,8))
lowPart = CDbl("&h" & Right(hDate,8))
intInstalledOn = highPart * (2^32) + lowPart
intInstalledOn = intInstalledOn / (60 * 10000000)
intInstalledOn = intInstalledOn / 1440
HexDateToDate = intInstalledOn + #1/1/1601#
End Function