Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting Date Modified Attribute of a specified File

1,697 views
Skip to first unread message

hemlatatripathi

unread,
Jan 24, 2006, 12:30:19 PM1/24/06
to
I need to get the Date Modified attribute of a file. which
windows SDK function in need to call, in order to get this
information.

Thanks
Hemlata

Millard F. Brown III

unread,
Jan 24, 2006, 1:09:51 PM1/24/06
to
Hemlata,

Look at the way of_GetLastWriteDateTime() in the PFC file services is
implemented.
--
Regards,
Millard [TeamSybase]

<Hemlata Tripathi> wrote in message
news:43d6642b.7f4...@sybase.com...

dash1b

unread,
Jan 27, 2006, 12:15:43 PM1/27/06
to
following is some code we used for an app in PB 6.5 no PFC.
You need to create the structures listed in the comments and add the
external function references as well.

Pass in the full path to the file, and 3 datetime reference variables
to get the 3 types of timestamps on a file. I believe the one you are
looking for (modified) is the 3rd one (adt_write).

// ***************************************************************
// iGetFileTime (32 bit only)
//
// Parms:
// by VALUE as_File = Name of file
// by REF adt_creation = Creation time
// by REF adt_access = Last access time
// by REF adt_write = Last write time
//
// Obtains creation, access and write times of the specified file
//
// Returns: True is successfull or False if failure
//
// REV DATE INIT REASON
//
// references:
// http://www.pmsys.com/pb
//
// *********** must also include the following external functions:
//Function Boolean CloseHandle(ulong hfile) Library "kernel32.dll"
//Function boolean FileTimeToSystemTime(ref filetime lpcreate, ref
systemtime lpsystem) //Library "kernel32.dll"
//Function boolean GetFileTime(ulong hfile, ref filetime lpcreate, ref
filetime lpaccess, ref //filetime lpwrite) Library "kernel32.dll"
//Function ulong OpenFile (ref string lpszFileName, ref str_ofstruct
ofstruct, uint fuMode) //Library "kernel32.dll"
// *********** must also include the following structures created:
//type str_ofstruct from structure
// long cBytes
// long fFixedDisk
// unsignedinteger nErrCode
// unsignedinteger Reserved1
// unsignedinteger Reserved2
// character szPathName[512]
//end type
//
//type filetime from structure
// ulong lowdate
// ulong highdate
//end type
//
//type systemtime from structure
// unsignedinteger wyear
// unsignedinteger wmonth
// unsignedinteger wdayofweek
// unsignedinteger wday
// unsignedinteger whour
// unsignedinteger wminute
// unsignedinteger wsecond
// unsignedinteger wmillisecond
//end type
//
// ***************************************************************


ulong hfile
boolean rtn
date ld_date
time lt_time
filetime lstr_create
filetime lstr_access
filetime lstr_write
systemtime lstr_system
str_ofstruct lstr_ofstruct
environment lstr_env

// Obtain our system environment
IF GetEnvironment(lstr_env) <> 1 THEN
MessageBox("Error","Error obtaining system environment!")
Halt
End If

CHOOSE CASE lstr_env.Win16
CASE True
MessageBox("Error","GetFileTime cannot be used in 16 bit
mode!")
Return -1
Case Else
hfile = OpenFile(as_file, lstr_ofstruct, 0)
If hfile<1 Then Return 0
rtn = GetFileTime(hfile, lstr_create, lstr_access, lstr_write)
If Not rtn Then Return 0
rtn = CloseHandle(hfile)
If Not rtn Then Return 0

// Convert dates
rtn = FileTimeToSystemTime(lstr_create,lstr_system)
If Not rtn Then Return 0
adt_creation = DateTime( &
Date( &
String(lstr_system.wmonth) + "/" + &
String(lstr_system.wday) + "/" + &
String(lstr_system.wyear)), &
Time( &
String(lstr_system.whour) + ":" + &
String(lstr_system.wminute) + ":" + &
String(lstr_system.wsecond)))
rtn = FileTimeToSystemTime(lstr_access,lstr_system)
If Not rtn Then Return 0
adt_access = DateTime( &
Date( &
String(lstr_system.wmonth) + "/" + &
String(lstr_system.wday) + "/" + &
String(lstr_system.wyear)), &
Time( &
String(lstr_system.whour) + ":" + &
String(lstr_system.wminute) + ":" + &
String(lstr_system.wsecond)))
rtn = FileTimeToSystemTime(lstr_write,lstr_system)
If Not rtn Then Return 0
adt_write = DateTime( &
Date( &
String(lstr_system.wmonth) + "/" + &
String(lstr_system.wday) + "/" + &
String(lstr_system.wyear)), &
Time( &
String(lstr_system.whour) + ":" + &
String(lstr_system.wminute) + ":" + &
String(lstr_system.wsecond)))

End Choose
Return -1

hemlatatripathi

unread,
Jan 31, 2006, 10:52:13 AM1/31/06
to
Unfortunately, we donot have pfc foundation in our project.
Can i get the actual windows system function to get this
system date.

Steve Katz [TeamSybase]

unread,
Feb 1, 2006, 12:27:00 AM2/1/06
to
You can install the PFC and use the help files and look through the
libraries without needing to deploy or use them in your application. Just
create a dummy target in your workspace so you have access to the code.

steve
[TeamSybase]

<Hemlata Tripathi> wrote in message

news:43df78dc.3c1...@sybase.com...

Millard F. Brown III

unread,
Mar 3, 2006, 5:46:23 PM3/3/06
to
In fact, you can quite easily lift entire functions out of parts of the PFC
like the file services. It is more loosely coupled that most of PFC.

--
Regards,
Millard [TeamSybase]

"Steve Katz [TeamSybase]" <steve...@teamsybase.com> wrote in message
news:43e046a4$1@forums-1-dub...

0 new messages