How to calculate the total execution time of each application Win (process) with the group on day.
For example: the process - notepad.exe - 10 minutes today (in total)
How to calculate the total execution time of each application Win (process) with the group on day.
For example: the process - notepad.exe - 10 minutes today (in total)
I would use a WMI query against Win32_Process and retrieve the CreationDate value which according to MSDN is the date (and time) a process began executing.
A good library for Delphi is available from Magenta Systems. This library includes several examples to help you get started.
This only tracks currently running processes. If your wanting to track processes which were run once but are no longer running, then you will want to hook into windows so you are notified at each application launch. One example of this would be to use the CBT hooks (computer based training, but its used for other things also) which allow you to get notified every time a window is created. If you use the window handle to then find the parent process, you can then use this to track for yourself how long the parent process is running.
The Win32 function GetProcessTimes is an alternative way of getting hold of the creation time and CPU time spent during the day. With execution time I assume you mean cpu time rather than wall clock time.
Here is a link to a blog post describing how to use GetProcessTimes in Delphi.
This is a more "direct" approach than using WMI, however WMI has other advantages such as being able to query other machines over the network.
As skamradt also suggests, this application needs to run continuously to track all starting and stopping processes.The only way I know of to get events on starting and stopping applications is to use WMI events. See this question for some more info on that as well as this Technet blog on scripting
The steps to do this would be to