예제 #1
0
 public IcoListData(string id, string name, string group, string icofile, string exec, int order, bool ShellEx, IcoListRegType t)
 {
     Type        = t;
     ID          = id;
     Name        = name;
     Group       = group;
     IcoFile     = icofile;
     Execute     = exec;
     Order       = order;
     UseShellEx  = ShellEx;
     InitSuccess = true;
     try
     {
         string FullPath = FileTools.GetFullPath(Environment.ExpandEnvironmentVariables(IcoFile));
         if (FullPath != null)
         {
             Ico = Icon.ExtractAssociatedIcon(Environment.ExpandEnvironmentVariables(FullPath));
         }
         else
         {
             Ico = Icon.ExtractAssociatedIcon(Environment.ExpandEnvironmentVariables(IcoFile));
         }
         if (Ico == null)
         {
             Ico = Resources.exec;
         }
     }
     catch
     {
         Ico = Resources.exec;
     }
 }
예제 #2
0
 public bool IDExists(string ID, IcoListRegType T)
 {
     foreach (IcoListData i in icos)
     {
         if (i.ID == ID && i.Type == T)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #3
0
        public static void DeleteIcon(string ID, IcoListRegType Type)
        {
            NamedPipeClientStream pipe = ConnectPipe();

            if (pipe == null)
            {
                return;
            }
            IcoListData ico = new IcoListData();

            ico.Action = IcoListAction.Delete;
            ico.ID     = ID;
            ico.Type   = Type;
            XmlSerializer ser = new XmlSerializer(typeof(IcoListData));

            ser.Serialize(pipe, ico);
            pipe.Flush();
            pipe.Close();
        }
예제 #4
0
        void InitRegistry(RegistryKey root, IcoListRegType T)
        {
            RegistryKey dir = root.OpenSubKey(RegKey, false);

            if (dir == null)
            {
                return;
            }
            foreach (string keyname in dir.GetSubKeyNames())
            {
                RegistryKey key = dir.OpenSubKey(keyname, false);
                if (key == null)
                {
                    continue;
                }
                IcoListData ico = new IcoListData(keyname, T, key);
                if (ico.InitSuccess == true)
                {
                    icos.Add(ico);
                }
            }
            dir.Close();
        }
예제 #5
0
        public bool DeleteIcon(string ID, IcoListRegType Type)
        {
            foreach (IcoListData ico in icos)
            {
                if (ico.ID == ID && ico.Type == Type)
                {
                    RegistryKey reg;
                    if (Type == IcoListRegType.User)
                    {
                        reg = Registry.CurrentUser.OpenSubKey(RegKey, true);
                    }
                    else
                    {
                        reg = Registry.LocalMachine.OpenSubKey(RegKey, true);
                    }

                    if (reg == null)
                    {
                        return(false);
                    }
                    reg.DeleteSubKeyTree(ID, false);
                    foreach (ListViewItem l in lstList.Items)
                    {
                        if (l.Tag == ico)
                        {
                            lstList.Items.Remove(l);
                            break;
                        }
                    }
                    icos.Remove(ico);
                    reg.Close();
                    return(true);
                }
            }
            return(false);
        }
예제 #6
0
 void THREADAddIconMethod(string id, string name, string group, string icofile, string exec, int order, bool ShellEx, IcoListRegType t)
 {
     icolist.AddIcon(id, name, group, icofile, exec, order, ShellEx, t);
 }
예제 #7
0
 void THREADDeleteIconMethod(string ID, IcoListRegType Type)
 {
     icolist.DeleteIcon(ID, Type);
 }
예제 #8
0
 public void THREADAddIcon(string id, string name, string group, string icofile, string exec, int order, bool ShellEx, IcoListRegType t)
 {
     this.BeginInvoke(new DelegateAddIcon(THREADAddIconMethod), id, name, group, icofile, exec, order, ShellEx, t);
 }
예제 #9
0
 public void THREADDeleteIcon(string ID, IcoListRegType Type)
 {
     this.BeginInvoke(new DelegateDeleteIcon(THREADDeleteIconMethod), ID, Type);
 }
예제 #10
0
 public IcoListData(string id, IcoListRegType t, RegistryKey reg)
 {
     Type = t;
     ID   = id;
     Name = Convert.ToString(reg.GetValue("Name", ""));
     if (Name == "")
     {
         return;
     }
     Group = Convert.ToString(reg.GetValue("Group", ""));
     if (Group == "")
     {
         return;
     }
     IcoFile = Convert.ToString(reg.GetValue("IcoFile", ""));
     if (IcoFile == "")
     {
         return;
     }
     Execute = Convert.ToString(reg.GetValue("Execute", ""));
     if (Execute == "")
     {
         return;
     }
     try
     {
         Order = Convert.ToInt32(reg.GetValue("Order"));
     }
     catch
     {
         return;
     }
     try
     {
         UseShellEx = Convert.ToInt32(reg.GetValue("UseShellEx")) == 1 ? true : false;
     }
     catch
     {
     }
     InitSuccess = true;
     try
     {
         string FullPath = FileTools.GetFullPath(Environment.ExpandEnvironmentVariables(IcoFile));
         if (FullPath != null)
         {
             Ico = Icon.ExtractAssociatedIcon(Environment.ExpandEnvironmentVariables(FullPath));
         }
         else
         {
             Ico = Icon.ExtractAssociatedIcon(Environment.ExpandEnvironmentVariables(IcoFile));
         }
         if (Ico == null)
         {
             Ico = Resources.exec;
         }
     }
     catch
     {
         Ico = Resources.exec;
     }
 }
예제 #11
0
        public static void AddIcon(string id, string name, string group, string icofile, string exec, int order, bool ShellEx, IcoListRegType t)
        {
            NamedPipeClientStream pipe = ConnectPipe();

            if (pipe == null)
            {
                return;
            }
            IcoListData ico = new IcoListData(id, name, group, icofile, exec, order, ShellEx, t);

            ico.Action = IcoListAction.Add;
            XmlSerializer ser = new XmlSerializer(typeof(IcoListData));

            ser.Serialize(pipe, ico);
            pipe.Flush();
            pipe.Close();
        }
예제 #12
0
        public void AddIcon(string id, string name, string group, string icofile, string exec, int order, bool ShellEx, IcoListRegType t)
        {
            foreach (IcoListData ico in icos)
            {
                if (ico.ID == id && ico.Type == t)
                {
                    if (DeleteIcon(id, t) == false)
                    {
                        return;
                    }
                    break;
                }
            }
            IcoListData newico = new IcoListData(id, name, group, icofile, exec, order, ShellEx, t);

            if (newico.InitSuccess == false)
            {
                return;
            }

            RegistryKey reg;

            if (t == IcoListRegType.User)
            {
                reg = Registry.CurrentUser.CreateSubKey(RegKey);
            }
            else
            {
                reg = Registry.LocalMachine.CreateSubKey(RegKey);
            }
            if (reg == null)
            {
                return;
            }

            RegistryKey sreg = reg.CreateSubKey(id);

            if (sreg == null)
            {
                return;
            }
            sreg.SetValue("Name", newico.Name);
            sreg.SetValue("IcoFile", newico.IcoFile);
            sreg.SetValue("Group", newico.Group);
            sreg.SetValue("Execute", newico.Execute);
            sreg.SetValue("Order", newico.Order, RegistryValueKind.DWord);
            sreg.SetValue("UseShellEx", newico.UseShellEx == true ? 1 : 0, RegistryValueKind.DWord);
            sreg.Close();
            reg.Close();
            AddIcon(newico);
            icos.Add(newico);
        }