#region Create a desktop shortcut, string desktop = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Desktop); string Dirpath = System.Environment.CurrentDirectory; String exepath = assembly.getexecutingassembly (). Location; System.Diagnostics.FileVersionInfo exeinfo = System.Diagnostics.FileVersionInfo.GetVersionInfo (ExePath); System.IO.File.Exists (String. Format (@ "{0}\ shortcut key name. lnk", DeskTop))) {//System.IO.File.Delete (string. Format (@ "{0}\ shortcut key name. lnk", desktop);//Delete the original desktop shortcut key way return;} WshShell shell = new WshShell (); Iwshshortcut shortcut = (iwshshortcut) shell. CreateShortcut (Environment.getfolderpath (Environment.SpecialFolder.DesktopDirectory) + "\ \" + "shortcut key name. lnk"); Shortcut. TargetPath = @exePath; Target file shortcut. WorkingDirectory = Dirpath; Destination Folder shortcut. WindowStyle = 1; The window state of the target application is divided into normal, maximized, and Minimized "1,3,7" shortcut. Description = "Automatic Update program"; Describes shortcut. IconLocation = string. Format (@ "{0}\64.ico", dirpath); Shortcut icon shortcut. Arguments = ""; shortcut. Hotkey ="Shift+delete"; Shortcut key shortcut. Save (); #endregion
WPF Create desktop shortcuts