LiteSetup创建快捷方式

梦想游戏人
目录:
C/C++

运行 生成的临时vbs脚本 来生成 桌面快捷方式

vbs脚本

Set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\KKPlayer.lnk")
oShellLink.TargetPath = "C:\Users\hk\Desktop\KKPlayer\KKPlayer.exe"
oShellLink.WindowStyle = 1
oShellLink.IconLocation = "C:\Users\hk\Desktop\KKPlayer\KKPlayer.exe,0"
oShellLink.WorkingDirectory =  "C:\Users\hk\Desktop\KKPlayer"
oShellLink.Save

cpp代码

void CLiteSetupUIDlg::CreateShortcut()
{
	fstream f;
	f.open("shortcut.vbs", ios::out);

	string cmd;
	f << "Set WshShell = WScript.CreateObject(\"WScript.Shell\")" << endl;
	f << "strDesktop = WshShell.SpecialFolders(\"Desktop\")" << endl;

	cmd = "set oShellLink = WshShell.CreateShortcut(strDesktop & \"\\";
	cmd += const_for_exe::_shortcut_name;
	cmd += ".lnk\")";
	f << cmd << endl;



	cmd = "oShellLink.TargetPath = \"";
	cmd += Utils::toAscii(path1.GetBuffer(0));
	cmd += "\\";
	cmd += const_for_exe::_shortcut_exe_name;
	cmd += "\"";

	f << cmd << endl;


	f << "oShellLink.WindowStyle = 1" << endl;


	cmd = "oShellLink.IconLocation = \"";
	cmd += Utils::toAscii(path1.GetBuffer(0));
	cmd += "\\";
	cmd += const_for_exe::_shortcut_exe_name;
	cmd += ",0";
	cmd += "\"";

	f << cmd << endl;



	cmd = "oShellLink.WorkingDirectory =  \"";
	cmd += Utils::toAscii(path1.GetBuffer(0));
	cmd += "\"";

	f << cmd << endl;


	f << "oShellLink.Save" << endl;


	f.flush();
	f.close();

	//system("shortcut.vbs");

	Utils::system_hide_cmd("cmd /c shortcut.vbs");



	Utils::DeleteFileForName("shortcut.vbs");


}
Scroll Up