帮我看看这段程序

skyhyp 2005-11-03 11:25:25
GetFileTime("C:\\a\\b\\c\\d.txt",CreationTime,LastAccessTime,LastWriteTime);

FileTimeToSystemTime(CreationTime,STime);

printf("%d\n",STime->wYear);

d.txt文件是存在的,为什么输出总是52685,我怎么样得到它的正确的值呢?

...全文
109 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
K 2005-11-04
  • 打赏
  • 举报
回复
HANDLE hFile;
FILETIME a,b,c,d;

hFile = CreateFile("c:\\mess.txt",
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);

GetFileTime(hFile,&a,&b,&c);
SYSTEMTIME s;
FileTimeToSystemTime(&a,&s);

printf("%d\n",s.wYear);
note_code 2005-11-03
  • 打赏
  • 举报
回复
BOOL GetFileTime(
HANDLE hFile,
LPFILETIME lpCreationTime,
LPFILETIME lpLastAccessTime,
LPFILETIME lpLastWriteTime
);

Parameters
hFile
[in] Handle to the files for which to get dates and times. The file handle must have been created with the GENERIC_READ access right. For more information, see File Security and Access Rights.
lpCreationTime
[out] Pointer to a FILETIME structure to receive the date and time the file was created. This parameter can be NULL if the application does not require this information.
lpLastAccessTime
[out] Pointer to a FILETIME structure to receive the date and time the file was last accessed. The last access time includes the last time the file was written to, read from, or, in the case of executable files, run. This parameter can be NULL if the application does not require this information.
lpLastWriteTime
[out] Pointer to a FILETIME structure to receive the date and time the file was last written to. This parameter can be NULL if the application does not require this information.
note_code 2005-11-03
  • 打赏
  • 举报
回复
第一个参数应该传文件的句柄吧.
可以用CreateFile()这个函数获取文件句柄.

64,636

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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