How to safely close external program like "VLC" from QT



  • i need to close external application currently running on my system from QT. (Like "VLC", "Virtual DJ") etc. [work on Windows and Linux both ]

    I searched and finally found Qprocess. I am searching for an example or tutorial to show me how to close external programs, but I am unable to find any solution. I am a newbie , so can anyone help me Please or show me a demo?

    Thanks.


  • Lifetime Qt Champion

    Hi,

    Are you starting these application from your own application ? If so how are you doing it ?

    Out of curiosity, why do you need such a feature ?



  • Hello @SGaist

    I have resolved this issue. But, It's good to see that there is someone who is always ready to help everyone. Thanks for your suggestions and support. :)

    Now, Actually In my application, I can close any running external program selected from a drop down list .

    For this I have created a method to get PID (Work for both windows and linux)

    QString My::getProcessIdsByProcessName(const char* processName, QStringList &Pids)
    {

    //code
    }

    and after getting PID's, I call appropriate function to close a particular application.

    Thanks!


  • Qt Champions 2016

    @Punit said:

    and after getting PID's, I call appropriate function to close a particular application.

    I'm curious as to what that function might be?



  • @kshegunov

    The only functions/methods i know are TerminateProcess (MSDN) or taskkill called from commandline :)


  • Qt Champions 2016

    @the_ said:

    The only functions/methods i know are TerminateProcess (MSDN) or taskkill called from commandline :)

    Me too. But I wouldn't call those safe (in the sense of the thread's topic), nor graceful ... :)



  • @kshegunov

    I did not say anything about save or graceful or something like that ;)


  • Qt Champions 2016

    @the_

    I did not say anything about save or graceful or something like that

    True. Whence my original question ... :)


  • Lifetime Qt Champion

    One thing to add to @kshegunov, terminating these applications ungracefully may have side effects on the stability of your system.



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.