Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert in64 to timestamp

Status
Not open for further replies.

dforce13

Programmer
Sep 15, 2008
6
BE
When reading a file, I want to extract the timestamp. Using a hexeditor I am seeing this things

Signed 64 : 128656353327520000
Timestamps WIN 64 : 11/09/2008 19:35:32

Now how can I, in my program, convert the int64 to the Win 64 timestamp ?
 
It would help to know where the file is coming from and where these values are coming from. If this is all Delphi, there would likely be a function somewhere to do this. But if it's something different, it would be necessary to know where the file is coming from and what format it is in in order to convert the value.

----------
Measurement is not management.
 
These values are coming from a file within the recyclebin of Windows Vista. The date shown is the date of deletion of the file.

Hexadecimal view
00 19 2F 8E 45 14 C9 01

This is the code I use to get the result.

myfile := TFileStream.Create('c:\temp\$IVVY9BY.xml', fmOpenRead or fmShareDenyWrite);
try
if (myfile.Seek(16, soFromBeginning) = 16) And
(myfile.Read(i, Sizeof(i)) = Sizeof(i)) then
showmessage(Format('Value is %d', ))
else
ShowMessage('Problem reading value');

When I use the above code I get the int64 but the problem is converting this to a timestamp ?
Or do I have to use another piece of code to get the timestamp ?
 
I believe WIndows still stores time as a type called SystemTime and Delphi works primarily through tDateTime (although there is also The TimeStamp format). The function SytemTimetoDateTime (or SystemTimeToTimeStamp) in SysUtils will make the conversion. from there you can convert to strings etc. Give it a try.
 
FileTimeToSystemTime and SystemTimeToFileTime are the procedures you are looking for. (Then you will need SystemTimeToDateTime...)

Here's a tutorial I wrote on the (general) subject some time ago:

Handling Dates and Time in Delphi

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top