[Interest] Windows Process Duration
Charley Bay
charleyb123 at gmail.com
Wed Jan 22 13:55:12 CET 2014
>
> 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/96eadfe3/attachment.html>
More information about the Interest
mailing list