4Rabbits
asked on
Whats the best way of getting the 3 Date & Time Files of a File.
Hi Experts!?
I'd Like to know your opinions on the best, shortest & quickest route to display all the Date & Times.
The 3 Dates & Times am after are Created, Modified & Accessed.
I'd be calling them calling from a Function, which is like..
memo1.lines.add('Created: '+GetDate(file, 1, long));
1=Created
2=Modified
3=Accessed
4=Created & Modified
ect..
should I use Case or If for that function?
but getting back to the Date & Time of the file.
I'd like to be able to display them in there true long format and short format.
long = Tuesday, February 14, 2006, 09:50:19
short = 14/02/06 09:50:19
Thanks
4R.
I'd Like to know your opinions on the best, shortest & quickest route to display all the Date & Times.
The 3 Dates & Times am after are Created, Modified & Accessed.
I'd be calling them calling from a Function, which is like..
memo1.lines.add('Created: '+GetDate(file, 1, long));
1=Created
2=Modified
3=Accessed
4=Created & Modified
ect..
should I use Case or If for that function?
but getting back to the Date & Time of the file.
I'd like to be able to display them in there true long format and short format.
long = Tuesday, February 14, 2006, 09:50:19
short = 14/02/06 09:50:19
Thanks
4R.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks meikl.
AmigoJack, for some reason I couldn't get it to work :(
errors here #error#
filetimetolocalfiletime(#e lem^#.tTim e, ft1);
thanks.
4R.
AmigoJack, for some reason I couldn't get it to work :(
errors here #error#
filetimetolocalfiletime(#e
thanks.
4R.
whoops - exactly that line: delete it :)
var
st1: systemtime;
s1: string;
p1: pchar;
begin
getmem(p1, 300);
filetimetolocalfiletime(el
filetimetosystemtime(ft1, st1);
getdateformat(LOCALE_USER_
s1:= strpas(p1)+ ' ';
gettimeformat(LOCALE_USER_
s1:= s1+ strpas(p1);
item.SubItems.Add(s1);
freemem(p1);
result:= s1;
end;
procedure listFileTimes(fname: string; DWORD iDateType= 0);
var
wfd: win32_find_data;
h1: thandle;
begin
h1:= findfirstfile(pchar(fname)
if h1= INVALID_HANDLE_VALUE then exit;
with form1.memo1.lines do begin
add('last write: '+ getDateTimeString(wfd.ftLa
add('created: '+ getDateTimeString(wfd.ftCr
add('last access: '+ getDateTimeString(wfd.ftLa
end;
windows.findclose(h1);
end;
you should try the example with a memo1 on your form. call it like this
listFileTimes('c:\boot.ini
listFileTimes('c:\boot.ini
havent tested it, but i know GetDateFormat() is working for giving the date in any format you like. plus FindFirstFile() gives you more rapid all file times. if you have any further questions dont bother :)