使用QFile的link方法可以非常方便的创建快捷方式
//建立桌面快捷方式
QString strAppPath = "C:/Windows/System32/notepad.exe";
QString strDesktopLink = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/";
strDesktopLink += "notepad.lnk";
QFile fApp(strAppPath);
fApp.link(strDesktopLink);
//建立开始菜单快捷方式
QString strMenuLink = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation) + "/";
strMenuLink += "notepad/";
QDir pathDir;
pathDir.mkpath(strMenuLink);
strMenuLink += "notepad.lnk";
fApp.link(strMenuLink);
需要完整代码请访问QtReleaseExamples
联系方式:
作者 | 郑天佐 |
---|---|
278969898 | |
主页 | http://www.camelstudio.cn |
邮箱 | camelsoft@163.com |
博客 | http://blog.csdn.net/zhengtianzuo06 |
github | https://github.com/zhengtianzuo |
QQ群 | 199672080 |