示例#1
0
 static string GetShortcutPath(ReflectedShell shell = null)
 {
     if (shell == null) {
         shell = new ReflectedShell();
     }
     var startup = shell.GetSpecialFolder("Startup");
     return Path.Combine(startup, "Caffeinated.lnk");
 }
示例#2
0
        static string GetShortcutPath(ReflectedShell shell = null)
        {
            if (shell == null)
            {
                shell = new ReflectedShell();
            }
            var startup = shell.GetSpecialFolder("Startup");

            return(Path.Combine(startup, "Caffeinated.lnk"));
        }
示例#3
0
 private void StartupChkBox_CheckedChanged(object sender, EventArgs e)
 {
     var shell = new ReflectedShell();
     var shortcut = GetShortcutPath(shell);
     var executable = Assembly.GetExecutingAssembly()
                              .GetName().CodeBase;
     if (StartupChkBox.Checked) {
         // create shortcut in startup items folder in start menu
         shell.CreateShortcut(shortcut, executable);
     }
     else {
         // remove shortcut if it exists
         File.Delete(shortcut);
     }
 }
示例#4
0
        private void StartupChkBox_CheckedChanged(object sender, EventArgs e)
        {
            var shell      = new ReflectedShell();
            var shortcut   = GetShortcutPath(shell);
            var executable = Assembly.GetExecutingAssembly()
                             .GetName().CodeBase;

            if (StartupChkBox.Checked)
            {
                // create shortcut in startup items folder in start menu
                shell.CreateShortcut(shortcut, executable);
            }
            else
            {
                // remove shortcut if it exists
                File.Delete(shortcut);
            }
        }