Esempio n. 1
0
        public static Dictionary <string, Models.Tuple <string, bool> > LoadStartupItems()
        {
            StartupItemHolderClass startupItemHolderClass = new StartupItemHolderClass();

            using (RegistryKey hkcrRun = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run")) {
                startupItemHolderClass.UpdateStartupDictionaryForKey(hkcrRun, true);
            }
            using (RegistryKey hkcrRunDisabled =
                       Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run-")) {
                startupItemHolderClass.UpdateStartupDictionaryForKey(hkcrRunDisabled, false);
            }
            using (RegistryKey hklmRun = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run")) {
                startupItemHolderClass.UpdateStartupDictionaryForKey(hklmRun, true);
            }
            using (RegistryKey hklmRunDisabled = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run-")) {
                startupItemHolderClass.UpdateStartupDictionaryForKey(hklmRunDisabled, false);
            }
            if (WindowsVer.Is64BitOs())
            {
                using (RegistryKey hklmWowRun = Registry.LocalMachine.OpenSubKey(@"Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Run")) {
                    startupItemHolderClass.UpdateStartupDictionaryForKey(hklmWowRun, true);
                }
            }
            return(startupItemHolderClass.StartupItemDictionary);
        }
 internal bool AddFolder(WindowsVer.Windows windowsOs)
 {
     string sendToPath = GetSendToFolderPath(windowsOs);
     WPFFolderBrowserDialog folderBrowserDialog = new WPFFolderBrowserDialog();
     if (folderBrowserDialog.ShowDialog() == true) {
         string folderPath = folderBrowserDialog.FileName;
         CreateShortcut(sendToPath, folderPath);
         return true;
     }
     return false;
 }
 internal bool AddFile(WindowsVer.Windows windowsOs)
 {
     string sendToPath = GetSendToFolderPath(windowsOs);
     OpenFileDialog openFileDialog = new OpenFileDialog();
     if (openFileDialog.ShowDialog() == true) {
         string folderPath = openFileDialog.FileName;
         CreateShortcut(sendToPath, folderPath);
         return true;
     }
     return false;
 }
Esempio n. 4
0
        internal void CreateShortcut(string sendToPath, string fullPath)
        {
            string       fileName = Path.GetFileNameWithoutExtension(fullPath);
            IWshShortcut shortcut;

            if (WindowsVer.Is64BitOs())
            {
                WshShell wshShell = new WshShell();
                shortcut = (IWshShortcut)wshShell.CreateShortcut(Path.Combine(sendToPath, fileName + ".lnk"));
            }
            else
            {
                WshShellClass wshShell = new WshShellClass();
                shortcut = (IWshShortcut)wshShell.CreateShortcut(Path.Combine(sendToPath, fileName + ".lnk"));
            }
            shortcut.TargetPath   = fullPath;
            shortcut.IconLocation = fullPath;
            shortcut.Save();
        }
 internal string GetSendToFolderPath(WindowsVer.Windows windowsOs)
 {
     if (!String.IsNullOrEmpty(_cachedSendToPath))
         return _cachedSendToPath;
     if (windowsOs == WindowsVer.Windows.Xp)
         _cachedSendToPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\SendTo";
     else
         _cachedSendToPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Windows\SendTo";
     return _cachedSendToPath;
 }