; 将系统时间设置为:2015年1月7日 8点37分27秒【中国是+8点,所以参数4:0 = 北京时间8点】
SetSystemTime(2022, 1, 7, 0, 37, 27)
; ===========================================================
; Function......: SetSystemTime
; DLL...........: Kernel32.dll
; Library.......: Kernel32.lib
; U/ANSI........:
; Author........: jNizM
; Modified......:
; Links.........: https://msdn.microsoft.com/en-us/library/ms724942.aspx
; https://msdn.microsoft.com/en-us/library/windows/desktop/ms724942.aspx
; ===========================================================
SetSystemTime(Year := 1601, Month := 1, Day := 1, Hour := 0, Minute := 0, Second := 0, Milliseconds := 0, DayOfWeek := 0) {
static
VarSetCapacity(SYSTEMTIME, 16)
, NumPut(Year, SYSTEMTIME, 0, "UShort"), NumPut(Month, SYSTEMTIME, 2, "UShort")
, NumPut(DayOfWeek, SYSTEMTIME, 4, "UShort"), NumPut(Day, SYSTEMTIME, 6, "UShort")
, NumPut(Hour, SYSTEMTIME, 8, "UShort"), NumPut(Minute, SYSTEMTIME, 10, "UShort")
, NumPut(Second, SYSTEMTIME, 12, "UShort"), NumPut(Milliseconds, SYSTEMTIME, 14, "UShort")
if !(DllCall("kernel32.dll\SetSystemTime", "Ptr", &SYSTEMTIME))
return DllCall("kernel32.dll\GetLastError")
return 1
}
/* C++
BOOL WINAPI SetSystemTime( // UInt
_In_ const SYSTEMTIME *lpSystemTime // Ptr (16)
);
typedef struct _SYSTEMTIME {
WORD wYear; // UShort 2 => 0
WORD wMonth; // UShort 2 => 2
WORD wDayOfWeek; // UShort 2 => 4
WORD wDay; // UShort 2 => 6
WORD wHour; // UShort 2 => 8
WORD wMinute; // UShort 2 => 10
WORD wSecond; // UShort 2 => 12
WORD wMilliseconds; // UShort 2 => 14
} SYSTEMTIME, *PSYSTEMTIME;
*/
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。

评论(0)