Hi,
I can't find the error in this code:



...
.data
...
szTimeFormat db "HH:mm:ss", 0
szListFormat db "%s %s %s %35s %13lu", 0
wfd WIN32_FIND_DATA <>
syst SYSTEMTIME <>
...
.code
...
invoke FileTimeToSystemTime, addr wfd.ftLastWriteTime, addr syst
invoke GetTimeFormat, 0, 0, addr syst, \
addr szTimeFormat, addr szTimeBuffer, 20
invoke GetDateFormat, 0, 0, addr syst, addr szDateFormat, \
addr szDateBuffer, 20

mov eax, MAXDWORD
mov ebx, wfd.nFileSizeHigh
imul ebx
add eax, wfd.nFileSizeLow
mov edx, eax

add lpTotalSize, edx

invoke wsprintf, addr szListBuffer, addr szListFormat, \
addr szAttribBuffer, addr szDateBuffer, \
addr szTimeBuffer, addr wfd.cFileName, edx
...


An example output:



d---- 25.07.2001 20:07:37 . 0
d---- 25.07.2001 20:07:37 .. 0
-a--- 04.05.2001 10:05:02 CMD.EXE 249104
-a--- 25.07.2001 20:07:30 konsole.asm 7797
-a--- 25.07.2001 20:06:02 konsole.bak 7817
-a--- 25.07.2001 20:07:37 konsole.exe 3584
-a--- 25.07.2001 20:07:37 konsole.obj 4341

Total Size: 272643 Byte(s)


The original filetimes are


25.07.2001 22:07 <DIR> .
25.07.2001 22:07 <DIR> ..
04.05.2001 12:05 249.104 CMD.EXE
25.07.2001 22:07 7.797 konsole.asm
25.07.2001 22:06 7.817 konsole.bak
25.07.2001 22:07 3.584 konsole.exe
25.07.2001 22:07 4.341 konsole.obj


How could this happen?
Posted on 2001-07-25 15:13:50 by bazik
Afternoon, Bazik.

I haven't tried this 'filetime' stuff before, however I did find that the example in the Platform SDK uses 'FileTimeToLocalFileTime' between 'GetFileTime' and 'FileTimeToSystemTime';).

According to the P/SDK info, 'FileTimeToLocalFileTime' converts the time to a local format - taking into account 'daylight savings'.

Q: What timezone are you in?:grin:

Cheers,
Scronty
Posted on 2001-07-25 17:45:17 by Scronty
>I haven't tried this 'filetime' stuff before, however I did find that
>the example in the Platform SDK uses 'FileTimeToLocalFileTime'
>between 'GetFileTime' and 'FileTimeToSystemTime';).

int GetTimeFormat(
LCID Locale, // locale for which time is to be formatted
DWORD dwFlags, // flags specifying function options
CONST SYSTEMTIME *lpTime, // time to be formatted ; <- uses SYSTEMTIME, so FileTimeToSystemTime should work
LPCTSTR lpFormat, // time format string
LPTSTR lpTimeStr, // buffer for storing formatted string
int cchTime // size, in bytes or characters, of the buffer
);



>Q: What timezone are you in? :grin:


GMT +01:00 (Germany). Hmm... but there are 2 hours substracted :grin:

Please try it, and report, if the Time is correct, or if you also have a difference. I attach the Programm. NOTE: There are only 2 Commands avaible right now: "exit" and "ll" (<- *NIX Users know that ;) ).
Enter "ll" for displaying a file & directory listing. Oh, and no "cd" implemted yet :) (just started this yesterday).
Posted on 2001-07-25 18:52:17 by bazik
Afternoon, Bazik.

I check your '*.exe' proggy.

GMT for Sydney is +10:00.
'Automatically adjust clock for daylight savings changes' is switched on. (This doesn't affect the proggy, though).

On my HDD:


konsole.zip......26/7/2001.........10:12am
konsole.exe.....26/7/2001.........1:50am


Your proggy:


konsole.zip......26/7/2001.........00:12am
konsole.exe.....25/7/2001.........15:50am


So it seems that you have to take into account the time zones.

Cheers,
Scronty
Posted on 2001-07-25 19:20:46 by Scronty
Ok, thanx! I'm gonna search for some sample Code on google :grin:
Posted on 2001-07-26 01:45:05 by bazik
Wow, got it!
Here's the working snippet:


...
.data
ft FILETIME <>
...
.code
...
[b]invoke FileTimeToLocalFileTime, addr wfd.ftLastWriteTime, addr ft[/b]
invoke FileTimeToSystemTime, addr ft, addr syst
invoke GetTimeFormat, 0, 0, addr syst, \
addr szTimeFormat, addr szTimeBuffer, 20
...


Thanx again, Scronty!
Posted on 2001-07-26 01:51:20 by bazik