QT judgment and open process (Windows side)

Source: Internet
Author: User

The QT program on the windows side often needs to open external programs (such as: Prog.exe), and it needs to be determined that the external program is only open.

1, judge whether there is prog.exe in the system

void Judge ()

{

Qprocess tasklist;

Tasklist.execute ("Tasklist", Qstringlist () << "-fi" << "imagename eq prog.exe");

}

2. Terminating the Prog.exe process in the system

void Kill ()

{

Qprocess Taskkill;

Taskkill.execute ("Taskkill", Qstringlist () << "-im" << "Prog.exe" << "-f");

}

3. Open External Program Prog.exe

void Open ()

{

Qprocess Newprog;

Newprog.start ("Prog.exe", Qstringlist () << "command");

}

Pan Wai 1:

Qprocess::execute ():----Open an external program in a blocking manner, and continue executing the current program only after the external program has finished executing. The standard output and standard errors of external programs are the standard output and standard errors that are redirected to the current program.

Qprocess::start ():----Open external programs as child processes, external processes and current processes do not interfere with each other, but the parent process of the external process is the current process.

Qprocess::startdetached ():----Open external programs in a separate way, the external process and the current process do not interfere with each other, the parent process of the external process is the INIT process of the system.

Pan Wai 2:

1. Tasklist-fi "imagename eq prog.exe"--Displays process information for the process named Prog.exe

2. Tasklist-fi "imagename ne prog.exe"--show process information that the process name is not Prog.exe

3. Tasklist-fi "PID eq 1111"--show process information of process number 1111

4. Taskkill-f-pid 1111--forcing the process to terminate process number 1111

5. Taskkill-f-im Prog.exe--forces the process tree to terminate for all processes named Prog.exe

6. Taskkill-f-fi "imagename eq prog.exe"--forces the process tree to terminate all processes named Prog.exe

http://blog.csdn.net/zuijinhaoma8/article/details/42061243

QT judgment and open process (Windows side)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.