/// <summary> /// Sets a value that determines what the friendly name of the file is. /// </summary> /// <param name="description">Friendly description of file type.</param> protected void SetDescription(string description) { if (!this.Exists) { throw new Exception("Extension does not exist"); } registryWrapper.Write(this.progId, string.Empty, description); ShellNotification.NotifyOfChange(); }
/// <summary> /// Sets a value that determines numerous shell options for extension as well as limitations on how extension properties can be edited by programs that honor <see cref="EditFlags"/> /// </summary> /// <param name="flags"><see cref="EditFlags"/> for program file type.</param> protected void SetEditFlags(EditFlags flags) { if (!this.Exists) { throw new Exception("Extension does not exist"); } //registryWrapper.Write(info.progId, "EditFlags", (uint)flags); registryWrapper.Write(this.progId, "EditFlags", flags); ShellNotification.NotifyOfChange(); }
/// <summary> /// /// </summary> /// <param name="icon"></param> protected void SetDefaultIcon(ProgramIcon icon) { if (!this.Exists) { throw new Exception("Extension does not exist"); } if (icon != ProgramIcon.None) { registryWrapper.Write(this.progId + "\\DefaultIcon", "", icon.ToString()); ShellNotification.NotifyOfChange(); } }
/// <summary> /// Sets a value that indicates the filter component that is used to search for text within documents of this type. /// </summary> /// <param name="file"><see cref="FileAssociationInfo"/> that provides specifics of the extension to be changed.</param> /// <param name="persistentHandler">Guid of filter component.</param> protected void SetPersistentHandler(FileAssociationInfo file, Guid persistentHandler) { if (!file.Exists) { throw new Exception("Extension does not exist"); } if (persistentHandler == Guid.Empty) { return; } this.registryWrapper.Write(file.extension + "\\" + PersistentHandler, string.Empty, persistentHandler); ShellNotification.NotifyOfChange(); }
/// <summary> /// Sets a value that determines if the file's extension will always be shown. /// </summary> /// <param name="value">Value that specifies if the file's extension should be always displayed.</param> protected void SetAlwaysShowExt(bool value) { if (!this.Exists) { throw new Exception("Extension does not exist"); } if (value) { registryWrapper.Write(this.progId, "AlwaysShowExt", string.Empty); } else { registryWrapper.Delete(this.progId, "AlwaysShowExt"); } ShellNotification.NotifyOfChange(); }
/// <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("DefaultIcon", true); if (tmpKey != null) { key.DeleteSubKeyTree("DefaultIcon"); } tmpKey = key.CreateSubKey("DefaultIcon"); 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(); }