日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內(nèi)最全I(xiàn)T社區(qū)平臺 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > 數(shù)據(jù)庫 > sybase > pb9獲取文件創(chuàng)建時間、最后修改時間及設(shè)置最后修改時間的方法

pb9獲取文件創(chuàng)建時間、最后修改時間及設(shè)置最后修改時間的方法

來源:程序員人生   發(fā)布時間:2014-05-31 18:12:51 閱讀次數(shù):6743次

    將以下內(nèi)容保存為本地文件n_cst_filetime.sru,然后導(dǎo)入pbl中
[cpp]
$PBExportHeader$n_cst_filetime.sru 
$PBExportComments$與文件時間有關(guān)的外部函數(shù) 
forward 
global type n_cst_filetime from nonvisualobject 
end type 
type os_filedatetime from structure within n_cst_filetime 
end type 
type os_fileopeninfo from structure within n_cst_filetime 
end type 
type os_finddata from structure within n_cst_filetime 
end type 
type os_securityattributes from structure within n_cst_filetime 
end type 
type os_systemtime from structure within n_cst_filetime 
end type 
end forward 
 
type os_filedatetime from structure 
    unsignedlong        ul_lowdatetime 
    unsignedlong        ul_highdatetime 
end type 
 
type os_fileopeninfo from structure 
    character        c_length 
    character        c_fixed_disk 
    unsignedinteger        ui_dos_error 
    unsignedinteger        ui_na1 
    unsignedinteger        ui_na2 
    character        c_pathname[128] 
end type 
 
type os_finddata from structure 
    unsignedlong        ul_fileattributes 
    os_filedatetime        str_creationtime 
    os_filedatetime        str_lastaccesstime 
    os_filedatetime        str_lastwritetime 
    unsignedlong        ul_filesizehigh 
    unsignedlong        ul_filesizelow 
    unsignedlong        ul_reserved0 
    unsignedlong        ul_reserved1 
    character        ch_filename[260] 
    character        ch_alternatefilename[14] 
end type 
 
type os_securityattributes from structure 
    unsignedlong        ul_length 
    string        ch_description 
    boolean        b_inherit 
end type 
 
type os_systemtime from structure 
    unsignedinteger        ui_wyear 
    unsignedinteger        ui_wmonth 
    unsignedinteger        ui_wdayofweek 
    unsignedinteger        ui_wday 
    unsignedinteger        ui_whour 
    unsignedinteger        ui_wminute 
    unsignedinteger        ui_wsecond 
    unsignedinteger        ui_wmilliseconds 
end type 
 
global type n_cst_filetime from nonvisualobject autoinstantiate 
end type 
  
type prototypes 
//獲得應(yīng)用程序名用 
//Function uint GetModuleFileNameA(ulong hModule,ref string lpFilename,ulong nSize) Library "kernel32.dll" //獲取應(yīng)用程序運行目錄 
 
//文件操作 
Function long FindFirstFileA (ref string filename, ref os_finddata findfiledata) library "kernel32.dll" 
Function boolean FindNextFileA (long handle, ref os_finddata findfiledata) library "kernel32.dll" 
Function boolean FindClose (long handle) library "kernel32.dll" 
Function long    OpenFile (ref string filename, ref os_fileopeninfo of_struct, ulong action) LIBRARY "kernel32.dll" 
Function boolean CloseHandle (long file_hand) LIBRARY "kernel32.dll" 
Function boolean GetFileTime(long hFile, ref os_filedatetime  lpCreationTime, ref os_filedatetime  lpLastAccessTime, ref os_filedatetime  lpLastWriteTime  )  library "kernel32.dll" 
Function boolean FileTimeToSystemTime(ref os_filedatetime lpFileTime, ref os_systemtime lpSystemTime) library "kernel32.dll" 
Function boolean FileTimeToLocalFileTime(ref os_filedatetime lpFileTime, ref os_filedatetime lpLocalFileTime) library "kernel32.dll" 
Function boolean SetFileTime(long hFile, os_filedatetime  lpCreationTime, os_filedatetime  lpLastAccessTime, os_filedatetime  lpLastWriteTime  )  library "kernel32.dll" 
Function boolean SystemTimeToFileTime(os_systemtime lpSystemTime, ref os_filedatetime lpFileTime) library "kernel32.dll" 
Function boolean LocalFileTimeToFileTime(ref os_filedatetime lpLocalFileTime, ref os_filedatetime lpFileTime) library "kernel32.dll"  
 
end prototypes 
 
type variables 
 
end variables 
 
forward prototypes 
public function integer of_getcreatedatetime (string as_filename, ref datetime adt) 
public function integer of_getlastwritedatetime (string as_filename, ref datetime adt) 
public function integer of_setlastwritedatetime (string as_filename, datetime adt) 
private function integer of_convertfiledatetimetopb (os_filedatetime astr_filetime, ref datetime adt) 
private function integer of_convertpbdatetimetofile (datetime adt, ref os_filedatetime astr_filetime) 
end prototypes 
 
public function integer of_getcreatedatetime (string as_filename, ref datetime adt);//得到文件創(chuàng)建的時間 
long ll_handle 
os_finddata    lstr_FindData 
 
// Get the file information 
ll_handle = FindFirstFileA(as_FileName, lstr_FindData) 
If ll_handle <= 0 Then Return -1 
FindClose(ll_handle) 
 
// Convert the date and time 
Return of_ConvertFileDatetimeToPB(lstr_FindData.str_CreationTime, adt) 
end function 
 
public function integer of_getlastwritedatetime (string as_filename, ref datetime adt);//得到文件最后修改的時間 
long    ll_handle 
os_finddata    lstr_FindData 
 
// Get the file information 
ll_handle = FindFirstFileA(as_FileName, lstr_FindData) 
If ll_handle <= 0 Then Return -1 
FindClose(ll_handle) 
 
// Convert the date and time 
Return of_ConvertFileDatetimeToPB(lstr_FindData.str_LastWriteTime, adt) 
end function 
 
public function integer of_setlastwritedatetime (string as_filename, datetime adt);//設(shè)置文件最后修改時間 
boolean lb_Ret 
long ll_handle 
os_filedatetime lstr_FileTime, lstr_Empty 
os_finddata lstr_FindData 
os_fileopeninfo lstr_FileInfo 
 
// Get the file information. 
// This is required to keep the Last Access date from changing. 
// It will be changed by the OpenFile function. 
ll_handle = FindFirstFileA(as_FileName, lstr_FindData) 
If ll_handle <= 0 Then Return -1 
FindClose(ll_handle) 
 
// Convert the date and time 
If of_ConvertPBDatetimeToFile(adt, lstr_FileTime) < 0 Then Return -1 
 
// Set the file structure information 
lstr_FileInfo.c_fixed_disk = "~000" 
lstr_FileInfo.c_pathname = as_FileName 
lstr_FileInfo.c_length = "~142" 
 
// Open the file 
ll_handle = OpenFile ( as_filename, lstr_FileInfo, 2 )  
If ll_handle < 1 Then Return -1 
  
lb_Ret = SetFileTime(ll_handle, lstr_Empty, lstr_FindData.str_LastAccessTime, lstr_FileTime) 
 
CloseHandle(ll_handle) 
 
If lb_Ret Then 
    Return 1 
Else 
    Return -1 
End If 
 
end function 
 
private function integer of_convertfiledatetimetopb (os_filedatetime astr_filetime, ref datetime adt);//轉(zhuǎn)換文件系統(tǒng)時間為PB時間 
os_filedatetime    lstr_LocalTime 
os_systemtime    lstr_SystemTime 
 
If Not FileTimeToLocalFileTime(astr_FileTime, lstr_LocalTime) Then Return -1 
 
If Not FileTimeToSystemTime(lstr_LocalTime, lstr_SystemTime) Then Return -1 
 
adt = datetime(blob(String(lstr_SystemTime.ui_wyear) + "-" + & 
             String(lstr_SystemTime.ui_WMonth) + "-" + & 
             String(lstr_SystemTime.ui_WDay) + ' ' + & 
             String(lstr_SystemTime.ui_wHour) + ":" + & 
             String(lstr_SystemTime.ui_wMinute) + ":" + & 
             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);//轉(zhuǎn)換文件系統(tǒng)時間為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 
 
程序中這樣調(diào)用即可:
[cpp]
n_cst_filetime ln 
string ls_file = 'C:Program FilesSybasePowerBuilder 9.0pb90.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創(chuàng)建時間:  ' + string(ldt_create, 'yyyy年mm月dd日, hh:mm:ss.fff') +& 
                            '~r~n修改日期:  ' + string(ldt_lastwrite, 'yyyy年mm月dd日, hh:mm:ss.fff') ) 
 

摘自 yyoinge的專欄
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: a在线播放| 日韩精品一区二区在线 | 91 中文字幕 | 在线免费观看av网站 | 四虎www4hu永久免费 | 国产日韩一区二区三区 | a在线免费 | 精品精品国产毛片在线看 | 97在线视频观看 | 黄色日b| 国产区在线观看 | 美女黄色在线观看 | 亚洲精品乱码久久久久久蜜糖图片 | 成人午夜视频网站 | 国产亚洲欧美一区 | 国产欧美日韩综合 | 日韩中文av | 精品视频在线免费看 | 国产精品久久久久久久久久 | 成人妇女免费播放久久久 | 国产精品成人一区二区网站软件 | 国内毛片毛片 | 欧美一级二级三级 | 欧美天天视频 | 国产爽爽爽 | 亚洲一区二区三区在线播放 | 高清视频一区 | av在线电影网站 | 99在线视频免费观看 | 97精品国产97久久久久久免费 | 波多野结衣av在线播放 | 成人性爱视频在线观看 | 免费网站污 | 九九资源站 | 久久天堂网 | 成人免费观看视频大全 | 欧美日韩激情在线一区二区三区 | 国产一卡久久电影永久 | 人与性欧美aa大片视频看 | 性史性dvd影片农村毛片 | 黄瓜视频在线免费欧美日韩在线看 |