_WinAPI_GetProcessTimes如何获取进程运行了多长时间
举个例子,就是我想知道qq在电脑上运行了多少秒,这个_WinAPI_GetProcessTimes该如何使用 能得到进程的创建时间,计算运行时间不就很简单了吗,_WinAPI_GetProcessTimes获取进程的创建时间,
_Now()获取当前时间,
_DateDiff()获取两个时间的经历时间。 本帖最后由 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)
$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")
谢谢,大神,果然高手阿 #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)
$tST = _Date_Time_FileTimeToSystemTime($tFT)
ConsoleWrite('!SciTE 运行: ' & _WinAPI_GetTimeFormat(0, $tST) & @CRLF)
EndIf
页:
[1]