C++怎样获得系统时间

来源:百度知道 编辑:UC知道 时间:2024/06/28 19:49:27
希望给个完整的代码,获得后的类型是什么,请说清楚
1楼的是重设系统时间,不大对头吧。我知道有CTime::GetCurrentTime(); 这个函数,但不知道要用什么头文件,请大家指点一下

#include <time.h>

time_t t;
time(&t);

可以用系统调用system(“date”);
返回值是int型的
不是啊,这样可以直接取出系统时间,你只要把值取出来就可以了

typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME;

可以是这样的一个结构体.
Header: Winbase.h.

This function retrieves the current system date and time. The system time is expressed in UTC.

void GetSystemTime(
LPSYSTEMTIME lpSystemTime
);
Parameters
lpSystemTime
[out] Pointer to a SYSTEMTIME structure to receive the current system date and time.
Return Values
None.

Requirements
OS Versions: Windows CE 1.0 and later.
Header: Winbase.h.
Link Library: Coredll.lib.

#include <windows.h>

// SetFileToCurrentTime - sets last write time to current system ti