Changing a File Time to the Current Time
The following example sets the last-write time for a file to the current system time using the SetFileTime function.// SetFileToCurrentTime - sets last write time to current system time
// Return value - TRUE if successful, FALSE otherwise
// hFile - must be a valid file handleBOOL SetFileToCurrentTime(HANDLE hFile)
{
FILETIME ft;
SYSTEMTIME st;
BOOL f; GetSystemTime(&st); // gets current time
SystemTimeToFileTime(&st, &ft); // converts to file time format
f = SetFileTime(hf, // sets last-write time for file
(LPFILETIME) NULL, (LPFILETIME) NULL, &ft); return f;
}
The following example sets the last-write time for a file to the current system time using the SetFileTime function.// SetFileToCurrentTime - sets last write time to current system time
// Return value - TRUE if successful, FALSE otherwise
// hFile - must be a valid file handleBOOL SetFileToCurrentTime(HANDLE hFile)
{
FILETIME ft;
SYSTEMTIME st;
BOOL f; GetSystemTime(&st); // gets current time
SystemTimeToFileTime(&st, &ft); // converts to file time format
f = SetFileTime(hf, // sets last-write time for file
(LPFILETIME) NULL, (LPFILETIME) NULL, &ft); return f;
}
解决方案 »
- 关于一个opencv的小程序 图像变形了。。
- 如何实现应用程序的开机启动呢?
- 在桌面上点击某个文件的右键,有一个选择“发送到”菜单,如何在“发送到”菜单中添加一个自己定义的子菜单?
- 恭喜自己MVP连任成功!!!
- Windows SDK学习过程中的问题
- 一个奇怪的关于CMenu析构的问题
- 请问在打印中如何获得打印页面的范围
- !象棋程序!!高分!答得好的我以后还会给分!我想做个针对用户提供的棋局的精确求解的电脑象棋解题工具。有兴趣的快进来!
- 莱鸟级提问,关于VC.NET,纯属送分,请求帮助呀,
- 本人用CDC::BitBlt实现的图象滚动(when KEYDWON),一顿一顿的,太慢了,在GDI下,如何优化 ?要求达到Acdsee的程度,理论,代码都可,若真正有帮助,另加300分
- 请问:哪儿有msdn下载?
- 这是我初次使用vector的一个练习,能否帮我看一下,怎样改进,尤其是我在最后注释中的问题
::GetSystemTime(&tm);
SYSTEMTIME* pTime;
::GetSystemTime(pTime);
因此你必须首先申明一个SYSTEMTIME结构,然后用这个结构的地址作为参数传递给GetSystemTime。