Exemplo n.º 1
0
        private List <StartupObject> EnumerateStartupFolder()
        {
            List <StartupObject> objList = new List <StartupObject>();
            string path = Environment.GetFolderPath(Environment.SpecialFolder.Startup); //Environment.SpecialFolder.CommonStartup
            IEnumerable <string> files = Directory.EnumerateFiles(path);

            foreach (string name in files)
            {
                if (name.EndsWith(".ini"))
                {
                    continue;
                }

                string objPath = name;

                if (name.EndsWith(".lnk"))
                {
                    Shell           shell = new Shell();
                    ShellLinkObject link  = shell.NameSpace(path).ParseName(Path.GetFileName(name)).GetLink;

                    objPath = link.Path;
                }

                StartupObject obj = new StartupObject();
                obj.Name = Path.GetFileNameWithoutExtension(name);
                obj.Path = objPath;
                obj.Type = StartupType.FOLDER;

                objList.Add(obj);
            }

            return(objList);
        }
Exemplo n.º 2
0
        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {
            deleteToolStripMenuItem.Visible       = false;
            openFolderToolStripMenuItem.Visible   = false;
            openRegistryToolStripMenuItem.Visible = false;
            openFilepathToolStripMenuItem.Visible = false;

            if (listView1.SelectedItems.Count > 0)
            {
                openFilepathToolStripMenuItem.Visible = true;
                deleteToolStripMenuItem.Visible       = true;

                try
                {
                    StartupObject obj = startupList.Single(x => x.ID.ToString() == listView1.SelectedItems[0].Name);

                    if (obj.Type == StartupType.FOLDER)
                    {
                        openFolderToolStripMenuItem.Visible = true;
                    }
                    else
                    {
                        openRegistryToolStripMenuItem.Visible = true;
                    }
                }
                catch (Exception)
                {
                }
            }
        }
Exemplo n.º 3
0
 private void openFilepathToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         StartupObject obj = startupList.Single(x => x.ID.ToString() == listView1.SelectedItems[0].Name);
         Debug.WriteLine(Path.GetDirectoryName(obj.Path));
         Process.Start(Path.GetDirectoryName(obj.Path));
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 4
0
        private void openFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                StartupObject obj = startupList.Single(x => x.ID.ToString() == listView1.SelectedItems[0].Name);

                Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.Startup));
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 5
0
        private List <StartupObject> EnumerateKey(RegistryKey key, StartupType type)
        {
            List <StartupObject> objList = new List <StartupObject>();

            foreach (string name in key.GetValueNames())
            {
                StartupObject obj = new StartupObject();
                obj.Name = name;
                obj.Path = FilterPath(key.GetValue(name).ToString());
                obj.Type = type;

                Debug.WriteLine(Path.GetDirectoryName(obj.Path));

                objList.Add(obj);
            }

            return(objList);
        }