[dllcall][系统时间]改变系统的时钟为指定的日期和时间

改变系统的时钟为指定的日期和时间,改变时间为将来的日期可能会导致计划任务提早运行!

请注意:改变时间为将来的日期可能会导致计划任务提早运行!

SetSystemTime("20051008142211")  ; 传递 时间戳 (本地的, 非 UTC).

SetSystemTime(YYYYMMDDHHMISS)
; 设置系统时钟为指定的日期和时间.
; 调用者必须确保传入的参数是有效的日期时间戳
; (本地时间, 非 UTC). 成功时返回非零值, 否则返回零.
{
    ; 把参数从本地时间转换为 UTC 以便用于 SetSystemTime().
    UTC_Delta -= A_NowUTC, Seconds  ; 取整后秒数会更精确.
    UTC_Delta := Round(-UTC_Delta/60)  ; 取整到最近的分钟数以确保精度.
    YYYYMMDDHHMISS += UTC_Delta, Minutes  ; 对本地时间应用偏移来转换到 UTC.

    VarSetCapacity(SystemTime, 16, 0)  ; 此结构由 8 个 UShort 组成 (即 8*2=16).

    StringLeft, Int, YYYYMMDDHHMISS, 4    ; YYYY (年份)
    NumPut(Int, SystemTime, 0, "UShort")
    StringMid, Int, YYYYMMDDHHMISS, 5, 2  ; MM (年中的月数, 1-12)
    NumPut(Int, SystemTime, 2, "UShort")
    StringMid, Int, YYYYMMDDHHMISS, 7, 2  ; DD (月中的天数)
    NumPut(Int, SystemTime, 6, "UShort")
    StringMid, Int, YYYYMMDDHHMISS, 9, 2  ; HH (24 小时制的小时数)
    NumPut(Int, SystemTime, 8, "UShort")
    StringMid, Int, YYYYMMDDHHMISS, 11, 2 ; MI (分钟数)
    NumPut(Int, SystemTime, 10, "UShort")
    StringMid, Int, YYYYMMDDHHMISS, 13, 2 ; SS (秒数)
    NumPut(Int, SystemTime, 12, "UShort")

    return DllCall("SetSystemTime", Ptr, &SystemTime)
}

 

 

给TA捐赠
共{{data.count}}人
人已捐赠
其他

[dllcall][rect]结构的例子2

2018-1-1 15:42:32

其他

[dllcall][com]使用 COM 从任务栏暂时地移除活动窗口

2018-1-1 15:56:55

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索