永发信息网

用api函数中的getfiletime如何得到最后修改日期

答案:2  悬赏:0  手机版
解决时间 2021-02-19 15:23
用api函数中的getfiletime如何得到最后修改日期
最佳答案
比较两个文件日期的函数:
of_comparefiletime(string file1,string file2)

//// 比较文件时间,-1 file1早;0 file1=file2;1 file1晚 else出错
long filehandle1,filehandle2;
long rtn;
filetime lpcreationtime,lplastaccesstime,filetime1,filetime2
boolean brtn1,brtn2;
//////////
filehandle1 = createfile( file1, generic_read, file_share_read, 0, open_existing, file_flag_random_access, 0 )
filehandle2 = createfile( file2, generic_read, file_share_read, 0, open_existing, file_flag_random_access, 0 )

if filehandle1 > 0 and filehandle2 > 0 then
// 检查文件日期
brtn1 = getfiletime( filehandle1, lpcreationtime, lplastaccesstime, filetime1 )
brtn2 = getfiletime( filehandle2, lpcreationtime, lplastaccesstime, filetime2 )
if brtn1 and brtn2 then
rtn = comparefiletime(filetime1,filetime2)
else
rtn = -200;
end if
else
rtn = -100;
end if
if filehandle1>0 then closehandle(filehandle1)
if filehandle2>0 then closehandle(filehandle2);
return rtn;

结构声明:
type filetime from structure
ulong lowdatetime
ulong highdatetime
end type

声明常量

constant integer max_path = 260
constant integer ofs_maxpathname = 128
public constant unsignedlong file_attribute_archive = 32
public constant unsignedlong file_attribute_compressed =2048
public constant unsignedlong file_attribute_directory = 16
public constant unsignedlong file_attribute_hidden = 2
public constant unsignedlong file_attribute_normal = 128
public constant unsignedlong file_attribute_readonly = 1
public constant unsignedlong file_attribute_system =4
public constant unsignedlong file_attribute_temporary =256
constant long generic_read = 2147483648
constant long generic_write = 1073741824
constant long create_new = 1
constant long create_always = 2
constant long open_existing = 3
constant long open_always=4
constant long file_share_read=1
constant long file_share_write=2
constant long file_flag_random_access = 268435456
constant long maxdword=65535

api声明:
function boolean closehandle ( long hobject) library "kernel32.dll"
function long createfile (ref string lpfilename, ulong dwdesiredaccess, ulong dwsharemode, ulong lpsecurityattributes, ulong dwcreationdisposition, ulong dwflagsandattributes, ulong htemplatefile) library "kernel32.dll" alias for "createfilea"
function long comparefiletime(ref filetime ft1,ref filetime ft2) library "kernel32.dll" alias for "comparefiletime"
function boolean getfiletime (ulong hfile, ref filetime lpcreationtime, ref filetime lplastaccesstime, ref filetime lplastwritetime ) library "kernel32.dll"

declare:
function boolean getfiledatetime(string lpfilename,uint nmode,ref string lpdate,ref string lptime) library "mhand.dll"

function:
para:
string as_filename
unsignedinteger ai_mode

script:
string ls_date,ls_time
datetime ldt_returnvalue

ls_date=space(10)
ls_time=space(8)

if not getfiledatetime(as_filename,ai_mode,ls_date,ls_time) then
setnull(ldt_returnvalue)
return ldt_returnvalue
end if

ldt_returnvalue=datetime(date(ls_date),time(ls_time))

return ldt_returnvalue
全部回答
用api函数:GetFileTime ulong hfile long rtn filetime lpcreate filetime lpaccess filetime lpwrite hfile = FileOpen("odbc.ini") rtn = GetFileTime(hfile, lpcreate, lpaccess, lpwrite) Messagebox("File Handle", String(hfile)) Messagebox("Return Code", string(rtn)) FileClose(hfile)
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
孟良崮战役纪念馆有多少烈士坟墓
炒股手机软件哪个好
缪斯酒吧消费很高么?
只有阳茎的中年女人,我今年四十岁,下阴只有
梦里梦见的事在现实中会不会发生
It is an imaginary line dividing the world
求助:开县到城口的班车时间表?
广西玉林恒生劳务派遣服务有限公司地址在什么
求曹格的歌《爷爷》的歌词
索尼xm50t手机nfc怎么用
-1
2oo7年的人是什么星座
一个星期早餐和午餐吃粥,晚上吃水果一个星期
标致30081.6T至尚版发动机故障灯亮是什么原因
我同桌的华义娟怎么了吗
推荐资讯
崔家庄村敬老院怎么去啊,有知道地址的么
建立企业全过程安全生产和职业健康管理制度,
傅村镇卫生院蒋晓兰口腔门诊地址在什么地方,
引领时尚在哪里啊,我有事要去这个地方
皮肤过敏干燥怎么补水
如来佛身后的守护神是谁
巢湖人家私房菜我想知道这个在什么地方
根据《环境影响评价技术导则地下水环境》,下
再求助一SQL,谢谢,BOM父件查询最底层物料
准格尔旗五家尧小学在什么地方啊,我要过去处
长途汽车票中的数字告诉我们哪些信息
老是刺痛,像针扎一样难受,而且老有尿意是怎
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?