找回密码
 加入
搜索
查看: 1895|回复: 4

[AU3基础] _WinAPI_GetProcessTimes如何获取进程运行了多长时间

[复制链接]
发表于 2017-1-22 14:36:16 | 显示全部楼层 |阅读模式
举个例子,就是我想知道qq在电脑上运行了多少秒,这个_WinAPI_GetProcessTimes该如何使用
发表于 2017-1-22 14:48:03 | 显示全部楼层
能得到进程的创建时间,计算运行时间不就很简单了吗,
_WinAPI_GetProcessTimes获取进程的创建时间,
_Now()获取当前时间,
_DateDiff()获取两个时间的经历时间。
发表于 2017-1-22 16:52:11 | 显示全部楼层
本帖最后由 zhuyl369 于 2017-1-22 17:06 编辑

闲的没事  代码都给你写出来了
#include <Date.au3>
#include <WinAPILocale.au3>
#include <WinAPIProc.au3>

Local $aFT, $tFT, $tST, $iID = ProcessExists('QQ.exe')
Local $ProcessCreTime,$NowLocTime,$iDateCalc
If $iID Then
    $aFT = _WinAPI_GetProcessTimes($iID)
    $tFT = _Date_Time_FileTimeToLocalFileTime($aFT[0])
    $tST = _Date_Time_FileTimeToSystemTime($tFT)
    $ProcessCreTime=_WinAPI_GetDateFormat(0, $tST)&" "&_WinAPI_GetTimeFormat(0, $tST)
EndIf
$NowLocTime=_Now ()
$iDateCalc=_DateDiff('s',$ProcessCreTime,$NowLocTime)
MsgBox(0,"运行时间",$iDateCalc&"s")
 楼主| 发表于 2017-1-22 19:19:01 | 显示全部楼层
谢谢,大神,果然高手阿
发表于 2017-1-31 09:28:28 | 显示全部楼层
#include <Date.au3>
#include <WinAPILocale.au3>
#include <WinAPIProc.au3>

Local $aFT, $tFT, $tST, $iID = ProcessExists('SciTE.exe')

If $iID Then
    $aFT = _WinAPI_GetProcessTimes($iID)
    $tFT = _Date_Time_FileTimeToLocalFileTime($aFT[0])
    $tST = _Date_Time_FileTimeToSystemTime($tFT)
    ConsoleWrite('!SciTE 运行: ' & _WinAPI_GetTimeFormat(0, $tST) & @CRLF)
EndIf
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-26 17:24 , Processed in 0.074521 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表