Hi, I haven't much experience with MASM32, so I want you to ask, how exactly use the API-funktion.
intensive googeln wasn helpfully.
I want to read the date from this file "C:\Huhu.txt"

Well done ... THX for you attention !
Posted on 2003-02-28 08:33:28 by Forginforcer
Search for CreateFile and ReadFile
Posted on 2003-02-28 10:06:08 by bazik
this could work:


.386
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.data

hFile dd 0
fileName db "thefilename.txt",0
msg db "Created:%lu%lu",13,10
db "Last Accessed:%lu%lu",13,10
db "Last Written to:%lu%lu",0
.data?

Created dd ?,?
LastAccessed dd ?,?
LastWrittenTo dd ?,?
buf db 128 dup (?)

.code
start:

invoke CreateFile, ADDR fileName,GENERIC_READ,FILE_SHARE_READ,0,\
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
cmp eax, INVALID_HANDLE_VALUE
jz _err

mov hFile, eax
invoke GetFileTime, eax, ADDR Created, ADDR LastAccessed, ADDR LastWrittenTo
test eax, eax
jz _err

invoke wsprintf, ADDR buf, ADDR msg, Created+4, Created, \
LastAccessed+4, LastAccessed,\
LastWrittenTo+4, LastWrittenTo

invoke MessageBox, NULL, ADDR buf, ADDR fileName, MB_OK
invoke CloseHandle, hFile
invoke ExitProcess, 0

_err:
invoke MessageBox, NULL, NULL, NULL, MB_OK
invoke CloseHandle, hFile
invoke ExitProcess, 0

end start


Created dd ?,?
LastAccessed dd ?,?
LastWrittenTo dd ?,?

are FILETIME-structs...64bits, and the low dword is first, followed by the high dword.
They are supposed to represent 'number of 100-nanosecond intervals since January 1, 1601.' the api-reference tells..
Posted on 2003-02-28 12:13:45 by david
Hey mani thanks !
I will test it immediately !

P.S. strenge, I did'n get a email-notification...
Posted on 2003-02-28 13:21:12 by Forginforcer
Hello david, thanks again.
I need with your sample.
I get strange results.
perhaps something ist wrong:

could someone help me ?

Thanks do erveryone !
Posted on 2003-02-28 14:15:02 by Forginforcer
What?! You can't convert the 100-nanosecond intervals since January 1, 1601 to a date and time format??? :grin:

Seriously, I don't know how to do that. Maybe somebody else knows..
Posted on 2003-02-28 14:46:45 by david
I found something, check out this api in the win32 api reference

BOOL FileTimeToLocalFileTime(

CONST FILETIME *lpFileTime, // pointer to UTC file time to convert
LPFILETIME lpLocalFileTime // pointer to converted file time
);

It should do the job of converting the nasty numbers.
Posted on 2003-02-28 14:48:54 by david
hm... its a little woody !
You dont know how to too ?
Posted on 2003-02-28 14:50:16 by Forginforcer
thanks for your attention david !
i have to use the command so(according to your sample) : INVOKE FileTimeToLocalFileTime, ADDR Created, ADDR newCreated
Posted on 2003-02-28 14:54:04 by Forginforcer
I have drunk too many beers to investigate further :(
But msdn seem to have some info
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/filetimetolocalfiletime.asp

good luck :alright:
Posted on 2003-02-28 15:06:41 by david
i wasn helpfully for me....

*cry cry cry cry cry*
Posted on 2003-03-01 03:25:05 by Forginforcer
Hi again Red Forginforcer :) , this will fix it hopefully:



.386
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.data

hFile dd 0
fileName db "thefilename.txt",0
msg db "Created %lu/%lu/%lu %lu.%lu.%lu",13,10
db "Last Accessed %lu/%lu/%lu %lu.%lu.%lu",13,10
db "Last Written to: %lu/%lu/%lu %lu.%lu.%lu",0

.data?

data dd 18 dup (?)
Created dd ?,?
LastAccessed dd ?,?
LastWrittenTo dd ?,?

systemCreated SYSTEMTIME <>
systemLastAccessed SYSTEMTIME <>
systemLastWrittenTo SYSTEMTIME <>
zoneInfo TIME_ZONE_INFORMATION <>

localCreated SYSTEMTIME <>
localLastAccessed SYSTEMTIME <>
localLastWrittenTo SYSTEMTIME <>

buf db 256 dup (?)

.code
start:

invoke CreateFile, ADDR fileName,GENERIC_READ,FILE_SHARE_READ,0,\
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
cmp eax, INVALID_HANDLE_VALUE
jz _err

mov hFile, eax
invoke GetFileTime, eax, ADDR Created, ADDR LastAccessed, ADDR LastWrittenTo
test eax, eax
jz _err

invoke FileTimeToSystemTime, ADDR Created, ADDR systemCreated
invoke FileTimeToSystemTime, ADDR LastAccessed, ADDR systemLastAccessed
invoke FileTimeToSystemTime, ADDR LastWrittenTo, ADDR systemLastWrittenTo
invoke GetTimeZoneInformation, ADDR zoneInfo
invoke SystemTimeToTzSpecificLocalTime, ADDR zoneInfo, ADDR systemCreated, ADDR localCreated
invoke SystemTimeToTzSpecificLocalTime, ADDR zoneInfo, ADDR systemLastAccessed, ADDR localLastAccessed
invoke SystemTimeToTzSpecificLocalTime, ADDR zoneInfo, ADDR systemLastWrittenTo, ADDR localLastWrittenTo

; typedef struct _SYSTEMTIME
; {
; WORD wYear;
; WORD wMonth;
; WORD wDayOfWeek;
; WORD wDay;
; WORD wHour;
; WORD wMinute;
; WORD wSecond;
; WORD wMilliseconds;
; } SYSTEMTIME, *PSYSTEMTIME;

mov ecx, 3
mov esi, OFFSET localLastWrittenTo
ASSUME esi:ptr SYSTEMTIME
@@:
movzx eax, [esi].wSecond
push eax
movzx eax, [esi].wMinute
push eax
movzx eax, [esi].wHour
push eax
movzx eax, [esi].wDay
push eax
movzx eax, [esi].wMonth
push eax
movzx eax, [esi].wYear
push eax
sub esi, 16
dec ecx
jnz @B
push OFFSET msg
push OFFSET buf
call wsprintf
add esp, 8+(6*4*3)
ASSUME esi:nothing

invoke MessageBox, NULL, ADDR buf, ADDR fileName, MB_OK
invoke CloseHandle, hFile
invoke ExitProcess, 0

_err:
invoke MessageBox, NULL, NULL, NULL, MB_OK
invoke CloseHandle, hFile
invoke ExitProcess, 0

end start
Posted on 2003-03-01 20:00:02 by david
Hallo david many THANKS !!!!!!!!
It's realy works !


How a can show me recognitory ?
Posted on 2003-03-03 11:50:58 by Forginforcer