Qt进阶-QProcess进程类打开Windows系统工具

Qt进阶-QProcess进程类打开Windows系统工具

  1. 添加头文件
#include <QProcess>

  1. 在按钮的槽函数中使用Qprocess的函数start()实现:
  • 打开计算器
QProcess *poc = new QProcess;
poc->start("C:\\Windows\\system32\\calc.exe");		//路径可省略,写成poc->start("calc.exe");

在这里插入图片描述


  • 打开绘图板
QProcess *poc = new QProcess;
poc->start("C:\\Windows\\system32\\mspaint.exe");

在这里插入图片描述


  • 打开记事本
QProcess *poc = new QProcess;
poc->start("C:\\Windows\\system32\\notepad.exe");

在这里插入图片描述


  • 打开屏幕键盘
QProcess *poc = new QProcess;
poc->start("C:\\Windows\\system32\\osk.exe");

在这里插入图片描述


  • 打开字符映射表
QProcess *poc = new QProcess;
poc->start("C:\\Windows\\system32\\charmap.exe");

在这里插入图片描述


  • 打开写字板
QProcess *poc = new QProcess;
poc->start("C:\\Windows\\system32\\write.exe");

在这里插入图片描述


  • 打开任务管理器
QProcess *poc = new QProcess;
poc->start("C:\\Windows\\system32\\taskmgr.exe");

在这里插入图片描述


  • 打开查看windows版本
QProcess *poc = new QProcess;
poc->start("C:\\Windows\\system32\\winver.exe");

在这里插入图片描述


  • 打开远程桌面
QProcess *poc = new QProcess;
poc->start("C:\\Windows\\system32\\mstsc.exe");

在这里插入图片描述


  • 打开设备管理器
QProcess *poc = new QProcess;
poc->start("mmc devmgmt.msc");

在这里插入图片描述

  • 在Win10可能会出现打不开屏幕键盘或设备管理器的情况,也可以使用以下方法:
system("start C:\\Windows\\System32\\devmgmt.msc");		//设备管理器
system("start C:\\Windows\\System32\\osk.exe");			//屏幕键盘
  • 使用QProcess执行cmd命令
QProcess p(0);
p.start("cmd", QStringList()<<"/c"<<"ping www.baidu.com");
p.waitForStarted();
p.waitForFinished();
QString strTemp=QString::fromLocal8Bit(p.readAllStandardOutput());

QMessageBox testMassage;
testMassage.setText(strTemp);
testMassage.exec();
  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值