QT中使用QProcess启用外部
程序启用外部程序,并可传参,默认第一个参数是exe路径!启动外部程序的
方法有以下两种:1、start()void QProcess::start ( const QString &program, const QStringList &arguments, OpenMode mode = ReadWrite )Starts the program program in a new process, passing the command line arguments in arguments. The OpenMode is set to mode. QProcess will immediately enter the Starting state. If the process starts successfully,QProcess will emit started()otherwise, error() will be emitted.Note that arguments that contain spaces are not passed to the process as separate arguments.Windows: Arguments that contain spaces are wrapped in quotes.Note: Processes are started asynchronously, which means the started() and error() signals may be delayed. Call waitForStarted() to make sure the process has started (or has failed to start) and those signals have been emitted.See also pid(), started(), and waitForStarted().2、使用QProcess::execute(), 不过使用此方法时程序会谈纤则最阻塞直到此方法执行的程序结束后返回,这时竖巧候可使用QProcess和QThread
这两个类结合使用的方法来处理,以防止在主 线程中调用而导致阻塞的情况先从QThread继承一个类,重新实现run()函数:答:1、使用QProcess::startDetached()方法,启动外部程序后立即返回;2、使用QProcess::execute(),不过使用此方法时程序会最阻塞直到此方法执行的程序结束后返回,这时候可使用QProcess和QThread这两个类结合使用的方法来处理,以防止在主含棚线程中调用而导致阻塞的情况先从QThread继承一个类,重新实现run()函数:Quote:class MyThread : public QThread{public:void run()}void MyThread::run(){QProcess::execute("notepad.exe")1、点击开始界面的下拉按钮
2、点击“任务管理器”
3、团尺点击“启动”塌乱高
4、在想要禁止的启动程序上右键,点击禁用即可禁止以后开机启动陪迅。
评论列表(0条)