String(lstr_SystemTime.ui_wSecond) + ":" + &
String(lstr_SystemTime.ui_wMilliseconds)))
Return 1
end function
private function integer of_convertpbdatetimetofile (datetime adt, ref os_filedatetime astr_filetime);//转换文件系统时间为PB时间
os_filedatetime lstr_LocalTime
os_systemtime lstr_SystemTime
lstr_SystemTime.ui_wyear = year(date(adt))
lstr_SystemTime.ui_WMonth = Month(date(adt))
lstr_SystemTime.ui_WDay = Day(date(adt))
lstr_SystemTime.ui_wHour = hour(time(adt))
lstr_SystemTime.ui_wMinute = Minute(time(adt))
lstr_SystemTime.ui_wSecond = Second(time(adt))
lstr_SystemTime.ui_wMilliseconds = Long(String(adt, "fff"))
If Not SystemTimeToFileTime(lstr_SystemTime, lstr_LocalTime) Then Return -1
If Not LocalFileTimeToFileTime(lstr_LocalTime, astr_FileTime) Then Return -1
Return 1
end function
on n_cst_filetime.create
call super::create
TriggerEvent( this, "constructor" )
end on
on n_cst_filetime.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on
程序中这样调用即可:
[cpp]
n_cst_filetime ln
string ls_file = 'C:\Program Files\
Sybase\PowerBuilder 9.0\pb90.exe'
datetime ldt_create, ldt_lastwrite
ln.of_getcreatedatetime( ls_file, ldt_create)
ln.of_getlastwritedatetime( ls_file, ldt_lastwrite)
messagebox('提示', '文件【' + ls_file + '】~r~n~r~n创建时间: ' + string(ldt_create, 'yyyy年mm月dd日, hh:mm:ss.fff') +&
'~r~n修改日期: ' + string(ldt_lastwrite, 'yyyy年mm月dd日, hh:mm:ss.fff') )
摘自 yyoinge的专栏
|