当前位置:网站首页>Qt设置应用程序开机自启 解决设置失败原因
Qt设置应用程序开机自启 解决设置失败原因
2022-08-01 20:22:00 【源客V】
一、设置方法
QSettings reg("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
bool flag = true;
if (flag) {
//设置开机自启注册表
QString strAppPath = QDir::toNativeSeparators(QCoreApplication::applicationFilePath());
reg.setValue("exeName", strAppPath);
}
else {
//取消开机自启注册表
reg.remove("exeName");
}
1.QDir::toNativeSeparators将路径的"/"替换为"\\"
1.使用QCoreApplication获取路径需要上述代码写在QApplication a(argc, argv);代码之后.
2."exeName"一般使用软件名称,也可以设置为其他文本.
二、查看设置是否成功
1.按下Win+R打开运行窗口,输入regedit,打开注册表编辑器
2.照"HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run"路径打开
看到下面有新添加的“exeName”配置项,路径正确,即成功。
边栏推荐
- 用户体验好的Button,在手机上不应该有Hover态
- Which websites are commonly used for patent searches?
- Does LabVIEW really close the COM port using VISA Close?
- An implementation of an ordered doubly linked list.
- MongoDB快速上手
- "Torch" tensor multiplication: matmul, einsum
- XSS靶场中级绕过
- Acrel-5010重点用能单位能耗在线监测系统在湖南三立集团的应用
- 解除360对默认浏览器的检测与修改
- 18. Distributed configuration center nacos
猜你喜欢
【节能学院】安科瑞餐饮油烟监测云平台助力大气污染攻坚战
Which websites are commonly used for patent searches?
部署zabbix
[Energy Conservation Institute] Comparative analysis of smart small busbar and column head cabinet solutions in data room
deploy zabbix
[Energy Conservation Institute] Ankerui Food and Beverage Fume Monitoring Cloud Platform Helps Fight Air Pollution
我的驾照考试笔记(4)
KDD2022 | 自监督超图Transformer推荐系统
虚拟机的IP地址自动变为127.0.0.1
内网穿透 lanproxy部署
随机推荐
Buttons with good user experience should not have hover state on mobile phones
[Energy Conservation Institute] Application of Intelligent Control Device in High Voltage Switchgear
[Personal work] Wireless network image transmission module
【nn.Parameter()】生成和为什么要初始化
【节能学院】安科瑞餐饮油烟监测云平台助力大气污染攻坚战
【Dart】dart之mixin探究
研究生新同学,牛人看英文文献的经验,值得你收藏
部署zabbix
互联网大厂研发流程
【kali-信息收集】(1.4)识别活跃的主机/查看打开的端口:Nmap(网络映射器工具)
[Energy Conservation Institute] Ankerui Food and Beverage Fume Monitoring Cloud Platform Helps Fight Air Pollution
Greenplum数据库源码分析——Standby Master操作工具分析
kingbaseV8R3和postgreSQL哪个版本最接近?
Application of Acrel-5010 online monitoring system for key energy consumption unit energy consumption in Hunan Sanli Group
使用微信公众号给指定微信用户发送信息
【ES】ES2021 我学不动了,这次只学 3 个。
regular expression
有序双向链表的实现。
大神经验:软件测试的自我发展规划
useful website