Re: Other information and dates of an archive
Hi CCris,
I made some modifications in your code.
I changed C_COOL for C_INT (C_BOOL is not declared) and
another things and it ran, but I am not getting the dates.
Please, try executes the code below.
Also I do not know how to follow your orientation when you
be says "you peek()ed".
Many thanks again.
Sérgio Gelli - Brasil
-- Eucode
include win32lib.ew
-----------------------------------------------------------------------------
procedure wwait(object messag )
atom result,rr
rr=getSelf()
if sequence (messag) then
result = message_box(messag ,"Mensagem !", MB_ICONEXCLAMATION + MB_TASKMODAL)
else
result = message_box(sprintf( "%d\n",messag),
"Mensagem !", MB_ICONEXCLAMATION + MB_TASKMODAL)
end if
-- setFocus(rr)
end procedure
-------------------------------------------------------------------------------
-- wrap a few functions from kernel32.dll
constant kernel32=open_dll("kernel32.dll"),
gft=define_c_func(kernel32,"GetFileTime",repeat(C_POINTER,4),C_INT),
ft2st=define_c_func(kernel32,"FileTimeToSystemTime",repeat(C_POINTER,2),C_INT),
cf=define_c_func(kernel32,"CreateFileA",repeat(C_POINTER,7),C_POINTER),
ch=define_c_func(kernel32,"CloseHandle",{C_POINTER},C_INT),
-- reserving some memory
mem_area=allocate(72),
-- area for raw data
create_time=mem_area,
last_access=mem_area+8,
last_write=mem_area+16,
-- area for usable data
system_create_time=mem_area+24,
system_last_access=mem_area+40,
system_last_write=mem_area+56,
-- this flag is used later: it tells the OS to fail upon opening a file
-- which doesn't exist
OPEN_EXISTING = 3
sequence fname
fname="C:\\ex.err" -- set this to the actual file name
atom hfile
integer rc
-- set hfile to a handle on your file
hfile=c_func(cf,{allocate_string(fname),
0,
0,
0,
OPEN_EXISTING,
0,
0})
if not hfile then
-- something went wrong, do something useful here
end if
-- now we have a file handle, let's get the timestamps
-- you may wish to check if rc=0, which notifies of an error
rc=c_func(gft,{hfile,create_time,last_access,last_write})
wwait(sprintf("rc=%d hfile =%d create_time=%s last_access=%s last_write=%s\n"&
"create_time=%d last_access=%d last_write=%d
",{rc,hfile,create_time,last_access,last_write,create_time,last_access,last_write}))
-- convert the data to something of use. Again, rc=0 means soething went wrong
rc=c_func(ft2st,{create_time,system_create_time})
wwait(sprintf("rc=%d create_time=%s system_create_time=%s \n"&
"create_time=%d system_create_time=%d ",
{rc,create_time,system_create_time,create_time,system_create_time}))
rc=c_func(ft2st,{last_access,system_last_access})
wwait(sprintf("rc=%d last_access=%s system_last_access=%s \n"&
"last_access=%d system_last_access=%d ",
{rc,last_access,system_last_access,last_access,system_last_access}))
rc=c_func(ft2st,{last_write,system_last_write})
wwait(sprintf("rc=%d last_write=%s system_last_write=%s \n"&
"last_write=%d system_last_write=%d ",
{rc,last_write,system_last_write,last_write,system_last_write}))
-- now close the file
rc=c_func(ch,{hfile})
--Now the data is available to be peek()ed at system_create_time,
--system_last_access and system_last_write respectively.
--Each of the three 16 bytes area is made of 8 fields 2 byte long each.
--They come in the following order:
--* Year
--* Month
--* DayOfWeek
--* Day
--* Hour
--* Minute
--* Second
--* Milliseconds
|
Not Categorized, Please Help
|
|