专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > VC

Vc.Net获取当前计算机时间?解决办法

发布时间:2011-06-23 14:14:19 文章来源:www.iduyao.cn 采编人员:星星草
Vc.Net获取当前计算机时间?
麻烦给个代码,另外要不要引用头文件捏!

------解决方案--------------------
DateTime::Now
------解决方案--------------------
DateTime dt = DateTime::Now;
labTimer->Text = dt.ToString(L"yyyy-MM-dd HH:mm:ss");
------解决方案--------------------
非托管的可以用
#include <windows.h>

// SetFileToCurrentTime - sets last write time to current system time
// Return value - TRUE if successful, FALSE otherwise
// hFile - must be a valid file handle

BOOL SetFileToCurrentTime(HANDLE hFile)
{
FILETIME ft;
SYSTEMTIME st;
BOOL f;

GetSystemTime(&st); // gets current time
SystemTimeToFileTime(&st, &ft); // converts to file time format
f = SetFileTime(hFile, // sets last-write time for file
(LPFILETIME) NULL, (LPFILETIME) NULL, &ft);

return f;
}
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: