예제 #1
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);
            }
        }
예제 #2
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");
        }