BrightnessTray.Autostart.CreateStartupFolderShortcut C# (CSharp) Метод

CreateStartupFolderShortcut() публичный статический Метод

public static CreateStartupFolderShortcut ( ) : void
Результат void
        public static void CreateStartupFolderShortcut()
        {
            WshShellClass wshShell = new WshShellClass();
            IWshRuntimeLibrary.IWshShortcut shortcut;
            string startUpFolderPath =
              Environment.GetFolderPath(Environment.SpecialFolder.Startup);

            // Create the shortcut
            shortcut =
              (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(
                startUpFolderPath + "\\" +
                PRODUCT_NAME + ".lnk");

            shortcut.TargetPath = Application.ExecutablePath;
            shortcut.WorkingDirectory = Application.StartupPath;
            shortcut.Description = "Launch BrightnessTray";
            shortcut.Arguments = String.Join(" ", Environment.GetCommandLineArgs().Skip(1));
            shortcut.Save();
        }

Usage Example

 private void AutostartMenuEventHandler(object sender, EventArgs e)
 {
     if (mnuAutostart.Checked)
     {
         // remove autostart entry
         Autostart.DeleteStartupFolderShortcut();
     }
     else
     {
         // create autostart entry
         Autostart.CreateStartupFolderShortcut();
     }
     mnuAutostart.Checked = Autostart.CheckStartupFolderShortcutsExists();
 }