Grupuri Google nu mai acceptă postările sau abonamentele noi Usenet. Conținutul anterior este în continuare vizibil.

Windows FILETIME

145 de afișări
Accesați primul mesaj necitit

Windows 2000

necitită,
8 mar. 2004, 13:25:4008.03.2004
Hello everybody,

as known, Windows stores time stamps in FILETIME format, a
8-Byte-Value. FILETIME format is the number of ticks, in 100ns
increments, since 00:00 1 Jan, 1601 (UTC). Since the rest of the world
uses the Unix definition of time, which is the number of seconds since
00:00 1 Jan 1970, we must be able to translate the FILETIME format to
the Unix time format. I heard, this is done with the following
equation:

(Unix Time) = A * (NT Time) + B

Since the ticks in FILETIME are at 100 nanoseconds intervals, we know
that "A" is 10^-7. The trick is finding "B". "B" is the number of
seconds between 1 Jan 1601 and 1 Jan 1970. This is documented with
MSDN and open source initiatives that "B" is 11644473600.

But if I calculate

Unix Time = 0,0000001 * 40B3B13FED2AC001 + 11644473600

I don't get a valid Unix Time. So what's wrong? Who can help me?

Thanx
Martin Besser

QuickHare

necitită,
8 mar. 2004, 14:13:5008.03.2004
Being a mathematician, I should be able to help.
The equation looks in the form Y = MX + C, or Y = (M * X) + C in computing
terms.
If you have M = A, then the remaining variables to find are Y, X and C.
Find a timestamp in both Unix and NT for the same time. These are the values for
Y and X.
Now a quick rearrangement gives C = Y - MX, or
B = (Unix Time) - A*(NT Time)
If you know A (as you say), and a time in both Unix and NT time, then B should
follow.

Hope this helps.
--
QuickHare
(QuickHare "at" Hotmail "dot" com)

Murphy McCauley

necitită,
8 mar. 2004, 14:42:2408.03.2004
"Windows 2000" <martin...@onlinehome.de> wrote in message
news:tgep409c58ffjjdrq...@4ax.com...

Well, you don't want to *add* 11644473600 -- you want to subtract it!
I tried it and it works fine...

Dim A As Double, B As Double
A = 10 ^ -7
B = 11644473600#

Dim NTTime As Double
NTTime = UnsignLong(FT.dwLowDateTime) + UnsignLong(FT.dwHighDateTime) * 2 ^
32#

Dim UnixTime As Long
UnixTime = A * NTTime - B

BTW, UnsignLong() takes a long, and returns it as a Double as if it were an
unsigned value, which is very important here.


Of course, using one of my libraries (available from my site), it's much
eaiser to just do...
UnixTime = DateToEpoch(FileTimeToDate(FT))


Murphy
www.ConstantThought.com


Mike Williams

necitită,
8 mar. 2004, 14:47:5108.03.2004
"Windows 2000" <martin...@onlinehome.de> wrote in message news:tgep409c58ffjjdrq...@4ax.com...

> The trick is finding "B". "B" is the number of seconds


> between 1 Jan 1601 and 1 Jan 1970. This is documented with
> MSDN and open source initiatives that "B" is 11644473600.

There's no trick, really. VB will tell you what it is:

Dim B As Currency
B = DateDiff("s", "1 Jan 1601", "1 Jan 1970")

Your other constant (0.0000001) is also correct. But you do have a problem with the sample FileTime you have used. Firstly, you haven't preceeded it with &H (to show that it is a hex string) but apart from that you are using a value that is simply not realistic (far too large). You have used the hex value:

40B3B13FED2AC001

whereas a file that is created today (8th March 2004) will have a FileTime of something like:

01C404A04C9F4000

So it would appear that you have a problem with the part of your code that is reading the FileTime (which you haven't posted).

Mike


0 mesaje noi