怎样通过API修改系统时间啊?

sadain 2005-05-09 06:18:22
rt
...全文
147 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
哦。晚到N步……
gzl 2005-05-12
  • 打赏
  • 举报
回复
SetLocalTime

The SetLocalTime function sets the current local time and date.


BOOL SetLocalTime(
const SYSTEMTIME* lpSystemTime
);

Parameters
lpSystemTime
[in] Pointer to a SYSTEMTIME structure that contains the current local date and time.
The wDayOfWeek member of the SYSTEMTIME structure is ignored.

Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
The SetLocalTime function enables the SE_SYSTEMTIME_NAME privilege before changing the local time. This privilege is disabled by default. For more information, see Running with Special Privileges.


Windows Server 2003, Windows XP/2000/NT: The system uses UTC internally. Therefore, when you call SetLocalTime, the system uses the current time zone information to perform the conversion, including the daylight saving time setting. Note that the system uses the daylight saving time setting of the current time, not the new time you are setting. Therefore, to ensure the correct result, call SetLocalTime a second time, now that the first call has updated the daylight saving time setting.


Requirements
Client: Included in Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, and Windows 95.
Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.


fvan 2005-05-09
  • 打赏
  • 举报
回复
SYSTEMTIME ct; //声明SYSTEMTIME结构的变量,声明后你可以付值
SetLocalTime(&ct)

//结构如下
typedef struct _SYSTEMTIME {
WORD wYear;
WORD wMonth;
WORD wDayOfWeek;
WORD wDay;
WORD wHour;
WORD wMinute;
WORD wSecond;
WORD wMilliseconds;
} SYSTEMTIME, *PSYSTEMTIME;


fvan 2005-05-09
  • 打赏
  • 举报
回复

SetLocalTime咯

2,643

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 硬件/系统
社区管理员
  • 硬件/系统社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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