FILETIME转化SYSTEMTIME

xiaoyuelove2 2006-11-10 03:39:19
情况是这样的
磁盘的一个扇区中写入了一些信息,要将他们读出来,而这个数据是LARGE_INTEGER m_SnapshotTime;定义在结构体中的,
CreateFile("\\\\.\\c:", // drive to open
GENERIC_READ, // no access to the drive
FILE_SHARE_READ | // share mode
FILE_SHARE_WRITE,
NULL, // default security attributes
OPEN_EXISTING, // disposition
0, // file attributes
NULL);
ReadFile (hDevice, Buffer, 512, &bytesread, NULL);
GetFileTime(hDevice, &ftCreate, &ftAccess, &ftWrite);
我想问问 我这个GetFileTime()获取的是什么?
我要怎么样才能将这个指向我需要的地址?
...全文
724 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
柯本 2006-11-10
  • 打赏
  • 举报
回复
这样才可以:
LPSYSTEMTIME lpSystemTime;
lpSystemTime=new SYSTEMTIME;
FileTimeToSystemTime(&ftCreate, lpSystemTime);

SYSTEMTIME lpSystemTime;
FileTimeToSystemTime(&ftCreate, &lpSystemTime);
下面改->为 .

异常是因为你的lpSystemTime没申请内存
westhod 2006-11-10
  • 打赏
  • 举报
回复
HANDLE hFile = (HANDLE)GetFileAttributes("src.txt");
FILETIME ftCreate;

GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite);

LPSYSTEMTIME lpSystemTime;
FileTimeToSystemTime(&ftCreate, lpSystemTime);

cout << lpSystemTime->wYear <<"-" << lpSystemTime->wMonth << "-" << lpSystemTime->wDay << endl;
cout << " " << lpSystemTime->wHour << ":" << lpSystemTime->wMinute << ":" <<lpSystemTime->wSecond << endl;
-----------------------------------------------------
这样怎么出现异常了,就是在cout时。
飞哥 2006-11-10
  • 打赏
  • 举报
回复
right
柯本 2006-11-10
  • 打赏
  • 举报
回复

FILETIME ftCreate,ftAccess,ftWrite;
GetFileTime(hDevice, &ftCreate, &ftAccess, &ftWrite);
得到文件的时间,格式为:
typedef struct _FILETIME { // ft
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME;
如果要转成系统时间格式,用
BOOL FileTimeToSystemTime(

CONST FILETIME *lpFileTime, // pointer to file time to convert
LPSYSTEMTIME lpSystemTime // pointer to structure to receive system time
);

而SYSTEMTIME格式为
typedef struct _SYSTEMTIME { // st
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;



hailongchang 2006-11-10
  • 打赏
  • 举报
回复
GetFileTime获得创建,最后一次访问,最后一次修改的时间,要指向你自己的地址,你要自己建一个FILETIME结构体指针

65,210

社区成员

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

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