如何使用GetFileTime Api函数?请赐教

liq2003 2002-11-06 08:54:21
//请看以下代码
//文件打开成功,但执行GetFileTime时返回不成功
//Function boolean GetFileTime(ulong hfile, ref filetime lpcreate, ref filetime lpaccess, ref filetime lpwrite) Library "kernel32.dll"

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)
...全文
539 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wu_07 2002-11-07
  • 打赏
  • 举报
回复
只好用api函数OpenFile,不知道怎么pb自带的fileopen不行
SYSTEMTIME lpSystemTime
filetime lpcreate
filetime lpaccess
filetime lpwrite
OFSTRUCT lpReOpenBuff
hfile = OpenFile(filename,lpReOpenBuff,0)

rtn = GetFileTime(hfile, lpcreate, lpaccess, lpwrite)
FileTimeToSystemTime(lpcreate,lpSystemTime)
Messagebox("creationtime", string(lpSystemTime.wyear)+"年"+string(lpSystemTime.wmonth)+"月"+string(lpSystemTime.wday)+"日")

FileClose(hfile)

结构
$PBExportHeader$ofstruct.srs
global type ofstruct from structure
character cbytes
character ffixeddisk
long nerrcode
long reserved1
long reserved2
character szpathname[128]
end type

函数
FUNCTION ulong OpenFile(ref string lpFileName,ref OFSTRUCT lpReOpenBuff,ulong wStyle) LIBRARY "kernel32.dll"
liq2003 2002-11-07
  • 打赏
  • 举报
回复
BLUETLCK:
非常感谢!
我已用VB做了一个,用Findfirstfile的
wu_07 2002-11-06
  • 打赏
  • 举报
回复
不太清楚

我这里pb7 winxp执行没有问题
liq2003 2002-11-06
  • 打赏
  • 举报
回复
非常感谢BLUETLCK的帮助。
现在还有点问题。运行时出现如下错误:

"0x10cf288f"指令引用的"0x0ff60f6c"内存。该内存不能为"read"。
(环境为windows 2000 server,PB6.5)
不知是何原因?
wu_07 2002-11-06
  • 打赏
  • 举报
回复
string filename="C:\powerbuilder\PbApi\WinApi.txt"
ulong hfile
long rtn
WIN32_FIND_DATA lpFindFileData
SYSTEMTIME lpSystemTime
filetime lpcreate
filetime lpaccess
filetime lpwrite
FILETIME lpFileTime
FindFirstFile(filename,lpFindFileData)
lpFileTime = lpFindFileData.creationtime

rtn = FileTimeToSystemTime(lpFileTime,lpSystemTime)
Messagebox("creationtime", string(lpSystemTime.wyear)+"年"+string(lpSystemTime.wmonth)+"月"+string(lpSystemTime.wday)+"日")


相关结构:
$PBExportHeader$win32_find_data.srs
global type WIN32_FIND_DATA from structure
unsignedlong fileattributes
filetime creationtime
filetime lastaccesstime
filetime lastwritetime
unsignedlong filesizehigh
unsignedlong filesizelow
unsignedlong reserved0
unsignedlong reserved1
character filename[260]
character alternatefilename[14]
end type

$PBExportHeader$filetime.srs
global type FILETIME from structure
ulong dwLowDateTime
ulong dwHighDateTime
end type

$PBExportHeader$systemtime.srs
global type SYSTEMTIME from structure
uint wYear
uint wMonth
uint wDayOfWeek
uint wDay
uint wHour
uint wMinute
uint wSecond
uint wMilliseconds
end type

函数定义
FUNCTION ulong FileTimeToSystemTime(ref FILETIME lpFileTime,ref SYSTEMTIME lpSystemTime) LIBRARY "kernel32.dll"
FUNCTION ulong FindFirstFile(ref string lpFileName,ref WIN32_FIND_DATA lpFindFileData) LIBRARY "kernel32.dll" ALIAS FOR "FindFirstFileA"
liq2003 2002-11-06
  • 打赏
  • 举报
回复
能否给一个getfiletime的范例

1,077

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧