in reply to How to find the create time of a file under MS

Here it is with calls to the Win32 API. I don't know if this is any more accurate, but it worked fine on my system.
#!/usr/bin/perl -w use strict; use Win32::API; use Win32API::File (qw/:ALL/); my $filename = "file.txt"; my $GetFileTime = new Win32::API("kernel32", "GetFileTime", ['N', 'P', + 'P', 'P' ], 'I'); my $hFile= CreateFile( $filename, GENERIC_READ(), FILE_SHARE_READ(), [], OPEN_EXISTING() , 0, []) or die "Can't re +ad file $filename"; my %filetime =( create=>undef,access=>undef,write=>undef ); for (keys %filetime) { $filetime{$_} = pack("LL", 0, 0); } $GetFileTime->Call($hFile,$filetime{'create'},$filetime{'access'},$fil +etime{'write'}); for (keys %filetime) { my $filetimepointer = $filetime{$_}; my $systemtime = pack("SSSSSSSS",0,0,0,0,0,0,0,0); my $FileToSystem = new Win32::API("kernel32", "FileTimeToSyste +mTime", ['P','P'] , 'I'); $FileToSystem->Call($filetimepointer,$systemtime); my($year,$month,$weekday,$day,$hour,$minute,$second,$msecond) += unpack("SSSSSSSS",$systemtime); printf ("$_ time:\t %d/%02d/%02d %02d:%02d:%02d", $month, $day +, $year ,$hour,$minute,$second); print "\n"; }

Replies are listed 'Best First'.
Re: Re: How to find the create time of a file under MS
by demerphq (Chancellor) on Jul 17, 2002 at 16:41 UTC
    Wow.

    Thanks a lot thunders!

    +++++

    Yves / DeMerphq
    ---
    Writing a good benchmark isnt as easy as it might look.