[QT笔记]创建快捷方式


创建快捷方式


	QString ProgramData = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\CompanyName\\";
	QString NewVerDabanjia = "快捷方式.lnk";
	//QString NewVerDabanjia = "快捷方式Alpha.lnk";
	QString UninstallNewVerDabanjia = "卸载快捷方式.lnk";
	
	QString ProgramLinkName = ProgramData;
	ProgramLinkName.append(NewVerDabanjia);

	QString UninstallLinkName = ProgramData;
	UninstallLinkName.append(UninstallNewVerDabanjia);

	QFile::link(QApplication::applicationFilePath(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).append("/").append(NewVerDabanjia));
	QFile::link(QApplication::applicationFilePath(), ProgramLinkName);
	QFile::link(currPath.append("/uninstall.exe"), UninstallLinkName);
	// 开始菜单
	QString OldVerDabanjia = "快捷方式.lnk";
	QString OldProgramLinkName = ProgramData;
	OldProgramLinkName.append(OldVerDabanjia);
	// 卸载
	QString UnInatallOldVerDabanjia = ProgramData;
	UnInatallOldVerDabanjia.append("卸载快捷方式.lnk");
	// 删除以前的快捷方式
	DataMgr::RemoveFile(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).append("/").append(OldVerDabanjia));
	DataMgr::RemoveFile(OldProgramLinkName);
	DataMgr::RemoveFile(UnInatallOldVerDabanjia);
	DataMgr::RemoveFile("C:\\Users\\Public\\Desktop\\快捷方式OLD.lnk");




你可能感兴趣的:(Qt笔记)