/// <summary> /// Adds single <see cref="ProgramVerb"/> that define the verb supported by this ProgID. /// </summary> /// <param name="verb">Single <see cref="ProgramVerb"/> that contains supported verb.</param> protected void AddVerbInternal(ProgramVerb verb) { RegistryKey root = RegistryWrapper.ClassesRoot; RegistryKey key = root.OpenSubKey(this.progId).OpenSubKey("shell", true); if (key == null) { key = root.OpenSubKey(this.progId, true).CreateSubKey("shell"); } RegistryKey tmpkey = key.OpenSubKey(verb.Name, true); if (tmpkey == null) { tmpkey = key.CreateSubKey(verb.Name); } key = tmpkey; tmpkey = key.OpenSubKey("command", true); if (tmpkey == null) { tmpkey = key.CreateSubKey("command"); } tmpkey.SetValue(string.Empty, verb.Command, RegistryValueKind.ExpandString); tmpkey.Close(); key.Close(); root.Close(); ShellNotification.NotifyOfChange(); }
/// <summary> /// Removes single <see cref="ProgramVerb"/> that define the verb supported by this ProgID. /// </summary> /// <param name="verb">Single <see cref="ProgramVerb"/> that contains supported verb.</param> public void RemoveVerb(ProgramVerb verb) { if (verb == null) { throw new NullReferenceException(); } RemoveVerb(verb.Name); }
public static void Run() { FileAssociationInfo associate = new FileAssociationInfo(".plist"); if (!associate.Exists) { associate.Create(); } associate.ContentType = "Application/PList"; associate.ProgID = "ProperityList"; ////if (associate.OpenWithList == null) //{ // associate.OpenWithList = new string[]{ // args // }; //} //else if(!associate.OpenWithList.Contains("args")) //{ // List<string> list = new List<string>(); // list.Add(args); // list.AddRange(associate.OpenWithList); // associate.OpenWithList = list.ToArray(); //} string args = Path.GetFullPath(Path.Combine(Application.StartupPath, "IPATools.PlistEditor.exe")) + " \"%1\""; string ico = Path.Combine(Application.StartupPath, "file.ico"); ProgramVerb open = new ProgramVerb("Open", args); ProgramAssociationInfo pai = new ProgramAssociationInfo(associate.ProgID); if (!pai.Exists) { pai.Create("ProperityList", open); } else { for (int i = 0; i < pai.Verbs.Length; i++) { if (pai.Verbs[i].Name.Equals("open", StringComparison.OrdinalIgnoreCase)) { pai.RemoveVerb(pai.Verbs[i]); pai.AddVerb(open); break; } } } pai.DefaultIcon = new ProgramIcon(ico); }
/// <summary> /// Adds single <see cref="ProgramVerb"/> that define the verb supported by this ProgID. /// </summary> /// <param name="verb">Single <see cref="ProgramVerb"/> that contains supported verb.</param> public void AddVerb(ProgramVerb verb) { AddVerbInternal(verb); }
/// <summary> /// Creates actual Programmatic Identifier key in registry that is used by other extensions. /// </summary> /// <param name="description">Friendly description of file type.</param> /// <param name="editFlags"><see cref="EditFlags"/> for program file type.</param> /// <param name="verb">Single <see cref="ProgramVerb"/> that contains supported verbs.</param> /// <returns><see cref="ProgramAssociationInfo"/> instance referring to specified extension.</returns> public ProgramAssociationInfo Create(string description, EditFlags editFlags, ProgramVerb verb) { return(Create(description, editFlags, new ProgramVerb[] { verb })); }
/// <summary> /// Creates actual Programmatic Identifier key in registry that is used by other extensions. /// </summary> /// <param name="verb">Single <see cref="ProgramVerb"/> that contains supported verb.</param> /// <returns><see cref="ProgramAssociationInfo"/> instance referring to specified extension.</returns> public ProgramAssociationInfo Create(ProgramVerb verb) { return(Create(string.Empty, EditFlags.None, new ProgramVerb[] { verb })); }
/// <summary> /// Sets an array of <see cref="ProgramVerb"/> that define the verbs supported by this ProgID /// </summary> /// <param name="verbs">Array of <see cref="ProgramVerb"/> that contains verbs to be set.</param> protected void SetVerbs(ProgramVerb[] verbs) { if (!this.Exists) throw new Exception("Extension does not exist"); RegistryKey root = Registry.ClassesRoot; RegistryKey key = root.OpenSubKey(this.progId, true); RegistryKey tmpKey = key.OpenSubKey("shell", true); if (tmpKey != null) { key.DeleteSubKeyTree("shell"); } tmpKey = key.CreateSubKey("shell"); foreach (ProgramVerb verb in verbs) { RegistryKey newVerb = tmpKey.CreateSubKey(verb.Name.ToLower()); RegistryKey command = newVerb.CreateSubKey("command"); command.SetValue(string.Empty, verb.Command, RegistryValueKind.ExpandString); command.Close(); newVerb.Close(); } ShellNotification.NotifyOfChange(); }
/// <summary> /// Adds single <see cref="ProgramVerb"/> that define the verb supported by this ProgID. /// </summary> /// <param name="verb">Single <see cref="ProgramVerb"/> that contains supported verb.</param> protected void AddVerbInternal(ProgramVerb verb) { RegistryKey root = Registry.ClassesRoot; RegistryKey key = root.OpenSubKey(this.progId).OpenSubKey("shell", true); if (key == null) { key = root.OpenSubKey(this.progId, true).CreateSubKey("shell"); } RegistryKey tmpkey = key.OpenSubKey(verb.Name, true); if (tmpkey == null) { tmpkey = key.CreateSubKey(verb.Name); } key = tmpkey; tmpkey = key.OpenSubKey("command", true); if (tmpkey == null) { tmpkey = key.CreateSubKey("command"); } tmpkey.SetValue(string.Empty, verb.Command, RegistryValueKind.ExpandString); tmpkey.Close(); key.Close(); root.Close(); ShellNotification.NotifyOfChange(); }
/// <summary> /// Removes single <see cref="ProgramVerb"/> that define the verb supported by this ProgID. /// </summary> /// <param name="verb">Single <see cref="ProgramVerb"/> that contains supported verb.</param> public void RemoveVerb(ProgramVerb verb) { if (verb == null) throw new NullReferenceException(); RemoveVerb(verb.Name); }
/// <summary> /// Creates actual Programmatic Identifier key in registry that is used by other extensions. /// </summary> /// <param name="description">Friendly description of file type.</param> /// <param name="editFlags"><see cref="EditFlags"/> for program file type.</param> /// <param name="verbs">Array of <see cref="ProgramVerb"/> that contains supported verbs.</param> /// <returns><see cref="ProgramAssociationInfo"/> instance referring to specified extension.</returns> public ProgramAssociationInfo Create(string description, EditFlags editFlags, ProgramVerb[] verbs) { if (this.Exists) { this.Delete(); } this.Create(); if (description != string.Empty) this.Description = description; if (editFlags != EditFlags.None) this.EditFlags = editFlags; this.Verbs = verbs; return this; }
/// <summary> /// Creates actual Programmatic Identifier key in registry that is used by other extensions. /// </summary> /// <param name="description">Friendly description of file type.</param> /// <param name="editFlags"><see cref="EditFlags"/> for program file type.</param> /// <param name="verb">Single <see cref="ProgramVerb"/> that contains supported verbs.</param> /// <returns><see cref="ProgramAssociationInfo"/> instance referring to specified extension.</returns> public ProgramAssociationInfo Create(string description, EditFlags editFlags, ProgramVerb verb) { return Create(description, editFlags, new ProgramVerb[] { verb }); }
/// <summary> /// Creates actual Programmatic Identifier key in registry that is used by other extensions. /// </summary> /// <param name="description">Friendly description of file type.</param> /// <param name="verbs">Array of <see cref="ProgramVerb"/> that contains supported verbs.</param> /// <returns><see cref="ProgramAssociationInfo"/> instance referring to specified extension.</returns> public ProgramAssociationInfo Create(string description, ProgramVerb[] verbs) { return Create(description, EditFlags.None, verbs); }
/// <summary> /// Creates actual Programmatic Identifier key in registry that is used by other extensions. /// </summary> /// <param name="verbs">Array of <see cref="ProgramVerb"/> that contains supported verbs.</param> /// <returns><see cref="ProgramAssociationInfo"/> instance referring to specified extension.</returns> public ProgramAssociationInfo Create(ProgramVerb[] verbs) { return Create(string.Empty, EditFlags.None, verbs); }
/// <summary> /// Creates actual Programmatic Identifier key in registry that is used by other extensions. /// </summary> /// <param name="verb">Single <see cref="ProgramVerb"/> that contains supported verb.</param> /// <returns><see cref="ProgramAssociationInfo"/> instance referring to specified extension.</returns> public ProgramAssociationInfo Create(ProgramVerb verb) { return Create(string.Empty, EditFlags.None, new ProgramVerb[] { verb }); }
//Add single verb without affecting existing verbs private void addSingleVerbButton_Click(object sender, EventArgs e) { string extension = (string)extensionsListBox.SelectedItem; ProgramAssociationInfo pa = new ProgramAssociationInfo(programIdTextBox.Text); if (!pa.Exists) { return; } AddVerbDialog d = new AddVerbDialog(); if (d.ShowDialog() == DialogResult.OK) { ProgramVerb[] verbs = pa.Verbs; ProgramVerb newVerb = new ProgramVerb(d.VerbName, d.VerbCommand); List<ProgramVerb> l = new List<ProgramVerb>(); if (!l.Contains(newVerb)) { pa.AddVerb(newVerb); refreshExtensionsButton_Click(null, null); extensionsListBox.SelectedItem = extension; } } }