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

Application Developer
Google # 606-887-9011
Cell # 606-792-0079
[email protected]<mailto:[email protected]>

“quidquid latine dictum sit altum videtur”


[cid:[email protected]]

On Jan 22, 2014, at 7:55 AM, Charley Bay 
<[email protected]<mailto:[email protected]>> 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


<<inline: image001.png>>

_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to