Process,Exist,Explorer.EXE
MsgBox,% "1:" GetProcessFullPath(ErrorLevel)
. "`n2:" GetProcessFullPath2(ErrorLevel)
. "`n3:" GetProcessFullPath("Explorer.EXE")
. "`n" GetProcessCreationTime(ErrorLevel)
;获取进程创建时间
GetProcessCreationTime(PID) {
hPr := DllCall( "OpenProcess", UInt,1040, Int,0, Int,PID )
DllCall( "GetProcessTimes", UInt,hPr, Int64P,UTC, Int,0, Int,0, Int,0 )
DllCall( "CloseHandle", Int,hPr)
DllCall( "FileTimeToLocalFileTime", Int64P,UTC, Int64P,Local ), AT := 1601
AT += % Local//10000000, S
FormatTime, AT, % AT, yyyy-MM-dd HH:mm:ss
Return AT
}
;获取进程文件路径,比ComObjGet可靠
GetProcessFullPath(ProcessNameOrPid) {
Process,Exist,%ProcessNameOrPid%
if ProcessId :=ErrorLevel {
hProcess := DllCall("Kernel32.dll\OpenProcess", "UInt", 0x0400|0x0010, "UInt", 0, "UInt", ProcessId)
FileNameSize := VarSetCapacity(ModuleFileName, (260 + 1) * 2, 0) / 2
if !(DllCall("Psapi.dll\GetModuleFileNameExW", "Ptr", hProcess, "Ptr", 0, "Str", ModuleFileName, "UInt", FileNameSize))
if !(DllCall("Kernel32.dll\K32GetModuleFileNameExW", "Ptr", hProcess, "Ptr", 0, "Str", ModuleFileName, "UInt", FileNameSize))
DllCall("Kernel32.dll\QueryFullProcessImageNameW", "Ptr", hProcess, "UInt", 1, "Str", ModuleFileName, "UIntP", FileNameSize)
return ModuleFileName, DllCall("Kernel32.dll\CloseHandle", "Ptr", hProcess)
}
}
;获取进程文件路径
GetProcessFullPath2(p_id) {
Try {
for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process where ProcessId=" p_id)
return process.ExecutablePath
}
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。