[DUG] Reading binary data as date/time from registry
Jan Bakuwel
jan.bakuwel at omiha.com
Fri May 14 12:06:01 NZST 2010
Hi Jolyon, Phil,
On 13/05/10 14:29, Jolyon Smith wrote:
> I'm not sure that reading the value as a Float (Double) is going to help...
> a TDateTime *IS* a double, so ReadFloat and ReadDateTime will operate read
> the data from the registry in *exactly* the same way.
>
> i.e:
>
> dt := TDateTime(reg.ReadFloat);
> dt := reg.ReadDateTime;
>
> are equivalent operations.
>
They are.
> If it is reading as zero then I'd suspect some sort of access/security
> problem on those keys in the registry though I can't think how it could
> contrive to return a zero rather than raising an exception.
>
It's not an access violation. I can read the 8 bytes when I use an
8-byte array just fine.
My problem is how to interpret these bytes.... I get the feeling that
Microsoft might store date/times in a slightly different format than
Delphi...
> Alternatively it may be some aspect of the conversion of the TDateTime to a
> string (presumably that is occurring in order to report a date being seen of
> "30/12/1899"), which may be falling foul of some oddity of the value in the
> TDateTime and returning the "zero" date as the "default in case of error"
> condition.
>
I first read the data into a TDateTime, then convert it to a string with
TDateTime.
> An oddity may arise as a result of the application that is WRITING the data
> not being a Delphi application and/or not storing it as a TDateTime
> compatible formatted value (if being used in a license check or similar
> sensitive information, as might be surmised from the value name, it is
> likely that even if it is a Delphi TDateTime value, that it is being
> obfuscated in some way to avoid external tampering etc).
>
You might be right about that (I hope not though).
Jan
More information about the Delphi
mailing list