Example #1
0
 public static void CreateShortcut(string Name, string NameIcon)
 {
     try{
         CreateIcon(NameIcon);
         if (!File.Exists(Path + @"\" + Name + ".lnk"))
         {
             ShellLink.CreateShortcut(Path, Name, ExePath, NameIcon, new ShellLink.Icon()
             {
                 Path = Path + @"\Image\" + NameIcon + ".ico", Index = 0
             });
         }
     } catch { }
 }
Example #2
0
        //public static void CreateShortcutForRunningApplication(string shortcutPath, bool overwrite = true) {
        //    CreateShortcutForApplication(Application.ExecutablePath, shortcutPath, overwrite);
        //}

        public static void CreateShortcutForApplication(string executablePath, string shortcutPath, bool overwrite = true, ShellLink.LinkDisplayMode displayMode = ShellLink.LinkDisplayMode.Normal)
        {
            using (ShellLink shortcut = new ShellLink()) {
                shortcut.Target           = executablePath;
                shortcut.WorkingDirectory = Path.GetDirectoryName(executablePath);
                shortcut.Description      = "My Shorcut Name Here";
                shortcut.DisplayMode      = displayMode;
                if (File.Exists(shortcutPath) && overwrite)
                {
                    File.Delete(shortcutPath);
                }
                shortcut.Save(shortcutPath);
            }
        }
Example #3
0
        public static void CreateShortcut(string path, string LinkName, string PathLink, string Arguments, Icon Icon = new Icon())
        {
            if (Icon.Path == "")
            {
                Icon.Path = PathLink; Icon.Index = 0;
            }
            ShellLink shortcut = new ShellLink();

            //string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            shortcut.Arguments        = Arguments;
            shortcut.Path             = PathLink;                             // Application.ExecutablePath.ToString();
            shortcut.WorkingDirectory = Directory.GetDirectoryRoot(PathLink); //Application.ExecutablePath
            shortcut.Description      = "H.m Soft";
            shortcut.IconIndex        = Icon.Index;
            shortcut.IconPath         = Icon.Path;// Application.ExecutablePath.ToString();
            shortcut.Save(path + @"\" + LinkName + ".lnk");
        }