public static void Create( string PathToFile, string PathToLink, string Arguments, string Description) { ShellLink.IShellLinkW shlLink = ShellLink.CreateShellLink(); Marshal.ThrowExceptionForHR(shlLink.SetDescription(Description)); Marshal.ThrowExceptionForHR(shlLink.SetPath(PathToFile)); Marshal.ThrowExceptionForHR(shlLink.SetArguments(Arguments)); ((System.Runtime.InteropServices.ComTypes.IPersistFile)shlLink).Save(PathToLink, false); }
private void CreateStartMenuShortcuts() { if (InstallationInfo.ToolsStartMenu == InstallationInfo.StartMenu.None) { return; } String smPath; if (InstallationInfo.ToolsStartMenu == InstallationInfo.StartMenu.AllUsers) { smPath = PackageUtility.ResolvePath(@"%AllUsersProfile%\Start Menu\Programs\Anolis"); } else { smPath = PackageUtility.ResolvePath(@"%UserProfile%\Start Menu\Programs\Anolis"); } DirectoryInfo startMenu = new DirectoryInfo(smPath); if (!startMenu.Exists) { startMenu.Create(); } String arLnkFn = Path.Combine(smPath, "Resourcer.lnk"); String arTarget = Path.Combine(InstallationInfo.ToolsDestination.FullName, "Anolis.Resourcer.exe"); String arDesc = "Extract, add and replace resources contained within applications"; ShellLink.CreateShellLink(arLnkFn, arTarget, arDesc); String pkLnkFn = Path.Combine(smPath, "Packager.lnk"); String pkTarget = Path.Combine(InstallationInfo.ToolsDestination.FullName, "Anolis.Packager.exe"); String pkDesc = "Create Anolis Packages and distribute them with a GUI installer"; ShellLink.CreateShellLink(pkLnkFn, pkTarget, pkDesc); }