Page 1 of 1

Windows: UptimePID()

Posted: Tue May 21, 2019 2:38 am
by sec
Windows: UptimePID(), the function will return the uptime in second of pid (process)

Code: Select all

Procedure.i UptimePID(pid.i) ; second
  creation.FILETIME 
  exit.FILETIME 
  kernel.FILETIME 
  user.FILETIME 
  stime.SYSTEMTIME
  ltime.SYSTEMTIME; 
  h = OpenProcess_(#PROCESS_QUERY_INFORMATION, #False, pid)  
  If h
    GetProcessTimes_(h,creation,exit,kernel,user) 
    FileTimeToSystemTime_(creation,stime);
    SystemTimeToTzSpecificLocalTime_(#Null,stime,ltime);
    ProcedureReturn Date() - Date(ltime\wYear,ltime\wMonth,ltime\wDay, ltime\wHour, ltime\wMinute, ltime\wSecond)
  EndIf
  ProcedureReturn 0
EndProcedure

Re: Windows: UptimePID()

Posted: Tue May 21, 2019 8:13 am
by RSBasic
Thank you for sharing.

Re: Windows: UptimePID()

Posted: Tue May 21, 2019 8:46 am
by BarryG
Good code, thank you. I have many uses for this.

Re: Windows: UptimePID()

Posted: Wed May 22, 2019 9:48 am
by Kwai chang caine
Works great on W7 X86
Thanks for sharing this usefull tip 8)

Re: Windows: UptimePID()

Posted: Wed May 22, 2019 10:47 am
by ar-s
Amazing.
Great possibilities. Thanks