[Interest] Windows Process Duration

Jason Kretzer Jason at gocodigo.com
Wed Jan 22 15:01:25 CET 2014


Thank you Bo and Charley.
- - - - - - - - - - - - - - - - - - - - - - -
Jason R. Kretzer

Application Developer
Google # 606-887-9011
Cell # 606-792-0079
Jason at gocodigo.com<mailto:Jason at gocodigo.com>

“quidquid latine dictum sit altum videtur”


[cid:image001.png at 01CECA4D.CA4030A0]

On Jan 22, 2014, at 7:55 AM, Charley Bay <charleyb123 at gmail.com<mailto:charleyb123 at gmail.com>> wrote:

Jason asketh:
> Is there a Qt way of getting a handle for a running windows process(or
> just checking if a certain .exe is currently executing) and determining
> how long it has been running?

 Bo respondeth:
No, this isn't something you can do in Qt. You have to do platform
specific code for it.

Which means it's now off topic on the Qt list, but here you go anyway :)

You can use EnumProcesses() to go through all the processes to find the
one you are looking for.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682629(v=vs.85).aspx

And GetProcessTimes to get the timing you need.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms683223(v=vs.85).aspx

I hope this helps,

Bo.

Under my ASSUMPTION that the process you want to "check-for" is YOUR application, the "Qt-Solutions" are add-ons with Windows-specific implementations, and you can use "qtsingleapplication" to find your already-running application:

https://qt.gitorious.org/qt-solutions/qt-solutions/source/80592b0e7145fb876ea0e84a6e3dadfd5f7481b6:

We use it, Qt4/Qt5, works great to check if the single application is running.  However, it does not track the duration for how long that application is running.  But, if it's your application, then you can easily establish a duration counter within the application, find it through "qtsingleapplication", and then communicate with the process to determine how long it has been running.

If it's NOT your application, though, then I defer back to Bo's answer.

--charley


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140122/5f7f2a06/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 13452 bytes
Desc: image001.png
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140122/5f7f2a06/attachment.png>


More information about the Interest mailing list