Hi Edward, Thanks for your reply. Would you know how I could read a date/time from the registry that is not written by Delphi?
The following three examples are all written with Delphi and can be read back just fine: 13 may 2010 12:56pm 03 ce dc 3f f1 ae e3 40 13 may 2010 12:57pm 39 75 33 48 f1 ae e3 40 13 may 2010 1:01pm 3e 47 d1 60 f1 ae e3 40 However, I am struggling to find a way to interpret: DateLastChecked REG_BINARY 95 a2 58 f2 2d f2 ca 01 as a date/time in Delphi. Reading it as binary data is fine, reading it as a TDateTime returns 30/12/1899. Jan On 13/05/10 17:22, Edward Koryagin wrote: > procedure TRegistry.WriteDateTime(const Name: string; Value: TDateTime); > begin > PutData(Name, @Value, SizeOf(TDateTime), rdBinary); > end; > > function RegDataToDataType(Value: TRegDataType): Integer; > begin > case Value of > rdString: Result := REG_SZ; > rdExpandString: Result := REG_EXPAND_SZ; > rdInteger: Result := REG_DWORD; > rdBinary: Result := REG_BINARY; > else > Result := REG_NONE; > end; > end; > > > procedure TRegistry.PutData(const Name: string; Buffer: Pointer; > BufSize: Integer; RegData: TRegDataType); > var > DataType: Integer; > begin > DataType := RegDataToDataType(RegData); > if RegSetValueEx(CurrentKey, PChar(Name), 0, DataType, Buffer, > BufSize) <> ERROR_SUCCESS then > raise ERegistryException.CreateResFmt(@SRegSetDataFailed, [Name]); > end; > > Edward Koryagin > > > --- On Thu, 13/5/10, Jan Bakuwel <jan.baku...@omiha.com> wrote: > > >> From: Jan Bakuwel <jan.baku...@omiha.com> >> Subject: [DUG] Reading binary data as date/time from registry >> To: "'NZ Borland Developers Group - Delphi List'" <delphi@delphi.org.nz> >> Received: Thursday, 13 May, 2010, 1:22 PM >> Hi, >> >> I'm struggling to find a good reference how I can read a >> date/time that >> is stored in the registry. Its stored in the registry by a >> Microsoft >> product; I'd like to read it with Delphi. >> >> Here are some examples: >> >> DateLastChecked REG_BINARY >> 95 a2 58 f2 2d f2 ca 01 >> >> When I write dates with Delphi >> (TRegistry.WriteDateTime(Now()), I get >> the following results: >> >> 13 may 2010 12:56pm 03 ce dc 3f >> f1 ae e3 40 >> 13 may 2010 12:57pm 39 75 33 48 >> f1 ae e3 40 >> 13 may 2010 1:01pm 3e 47 >> d1 60 f1 ae e3 40 >> >> The last 4 bytes seem to resemble the date, the first the >> time. >> >> When I use TRegistry.ReadDateTime on those entries, I get >> 30/12/1899. >> >> Suggestions are very welcome! >> >> thanks, >> Jan >> >> _______________________________________________ >> NZ Borland Developers Group - Delphi mailing list >> Post: delphi@delphi.org.nz >> Admin: http://delphi.org.nz/mailman/listinfo/delphi >> Unsubscribe: send an email to delphi-requ...@delphi.org.nz >> with Subject: unsubscribe >> >> > > > > > _______________________________________________ > NZ Borland Developers Group - Delphi mailing list > Post: delphi@delphi.org.nz > Admin: http://delphi.org.nz/mailman/listinfo/delphi > Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: > unsubscribe > > _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe