以编程方式获取上次启动/关闭时间

编程入门 行业动态 更新时间:2024-10-10 02:24:22
本文介绍了以编程方式获取上次启动/关闭时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想获取关闭和启动Windows的确切时间. 在c ++中,我只使用GetTickCount64即可检索自系统启动以来经过的毫秒数(从而通过时间来获取时间),但是我不知道python是否具有等效的功能,如果可能的话,我想避免编写一个c ++模块.

I'd like to get the exact time when windows was shut down and booted. In c++ I'd simply use GetTickCount64 which retrieves the number of milliseconds that have elapsed since the system was started (thus obtaining the time by difference), but I don't know if there is an equivalent function for python and, if possible, I'd like to avoid to write a c++ module.

对于上次关闭时间,我不知道...也许在Windows中某处有一些日志?我尝试使用win32evtlog库读取事件日志,但是它只给我一个事件,并且是关于dns的.

For last shutdown time I have no idea...maybe there is some log somewhere in windows? I tried to read the event log using win32evtlog library, but it gives me just an event and is about the dns..

好的,也许我可以走得更远:我使用了win32evtlog,尤其是多次调用ReadEvent日志,它将为我提供所有日志,直到返回null. 现在,我需要一种方法来了解有关启动/关闭的ID.

edit: Ok, maybe I got a step further: I used win32evtlog, in particular calling ReadEvent log more times it gives me all logs till it returns null. Now, I need a way to understand what ids are about boot/shutdown..

推荐答案

您应该使用pywin32库,然后在其中找到GetTickCount()函数.

You should use the pywin32 library, and there you'll find the GetTickCount() function.

docs.activestate/activepython/2.5/pywin32/win32api__GetTickCount_meth.html

希望这会有所帮助.

更多推荐

以编程方式获取上次启动/关闭时间

本文发布于:2023-11-09 23:20:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573717.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方式   时间

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!