| Ferrysoft | Registry Module | |||||||||||||||||||||||||||||||||||||||||||||
| Home Products Support Development Contact | ||||||||||||||||||||||||||||||||||||||||||||||
|
Registry Module Overview The Ferrysoft Registry Module is a class for manipulating the Registry. The Registry Module is provided in source code form (Visual Basic 2005/2008 compatible and Visual C# 2005/2008 compatible). It is intended for developers, to incorporate into their own applications, in order to provide support to the application for getting, setting and deleting values in the Registry. The module can be used, royalty-free, by any individual or organisation that purchases the module. As the module is provided in source code form, it can be modified as necessary after purchase, provided that any derived module is not distributed, in source code form, to a third party. The module can be incorporated into a commercial product and sold to third parties, in compiled format, provided that the purpose of the commercial product is not simply to act as a wrapper for the Registry Module. Buy It
The Registry Module is priced in Pounds Sterling (GBP), US Dollars (USD) and Euros (EUR).
Summary The Ferrysoft Registry Module is a wrapper class for the Microsoft.Win32.Registry and Microsoft.Win32.RegistryKey class libraries. It has the following advantages over using the Microsoft.Win32.Registry and Microsoft.Win32.RegistryKey class libraries natively:
Summary of properties provided by the class The properties provided by the class are described in the following table.
Summary of methods provided by the class The methods provided by the class are described in the following table. The permission column specifies the minimum required RegistryPermission to execute the method. There are several variants of each method.
Constructor Syntax Visual Basic Friend Sub New( _ ByVal ParentKeyType As Ferrysoft.Registry.ParentKeyType, _ ByVal SubKeyType As Ferrysoft.Registry.SubKeyType) C# internal Registry( Ferrysoft.Registry.ParentKeyType ParentKeyType, Ferrysoft.Registry.SubKeyType SubKeyType) Parameters
DefaultParentKeyType property Syntax Visual Basic Friend Property DefaultParentKeyType _ As Ferrysoft.Registry.ParentKeyType C# internal Ferrysoft.Registry.ParentKeyType DefaultParentKeyType { get; set; } Using the DefaultParentKeyType property Get/Set the default parent key type for use in methods where the parent key type is not specified. This property is initialised by the constructor. The property can be set to any of the following enumerations of Ferrysoft.Registry.ParentKeyType:
DefaultSubKey property Syntax Visual Basic Friend Property DefaultSubKey As String C# internal string DefaultSubKey { get; set; } Using the DefaultSubKey property Get/Set the default sub key for use in methods where the sub key is not specified. This property is initialised by the constructor. An example of a typical sub key is:
GetValue methods Syntax Visual Basic Friend Overloads Function GetValue( _ ByVal Name As String) As String Friend Overloads Function GetValue( _ ByVal Name As String, _ ByVal DefaultValue As String) As String Friend Overloads Function GetValue( _ ByVal Name As String, _ ByVal ParentKeyType As Ferrysoft.Registry.ParentKeyType) _ As String Friend Overloads Function GetValue( _ ByVal Name As String, _ ByVal DefaultValue As String, _ ByVal ParentKeyType As Ferrysoft.Registry.ParentKeyType) _ As String Friend Overloads Function GetValue( _ ByVal Name As String, _ ByVal ParentKeyType As Ferrysoft.Registry.ParentKeyType, _ ByVal SubKey As String) As String Friend Overloads Function GetValue( _ ByVal Name As String, _ ByVal DefaultValue As String, _ ByVal ParentKeyType As Ferrysoft.Registry.ParentKeyType, _ ByVal SubKey As String) As String C# internal string GetValue( string Name) internal string GetValue( string Name, string DefaultValue) internal string GetValue( string Name, Ferrysoft.Registry.ParentKeyType ParentKeyType) internal string GetValue( string Name, string DefaultValue, Ferrysoft.Registry.ParentKeyType ParentKeyType) internal string GetValue( string Name, Ferrysoft.Registry.ParentKeyType ParentKeyType, string SubKey) internal string GetValue( string Name, string DefaultValue, Ferrysoft.Registry.ParentKeyType ParentKeyType, string SubKey) Parameters
SetValue methods Syntax Visual Basic Friend Overloads Sub SetValue( _ ByVal Name As String, _ ByVal Value As String) Friend Overloads Sub SetValue( _ ByVal Name As String, _ ByVal Value As String, _ ByVal ParentKeyType As Ferrysoft.Registry.ParentKeyType) Friend Overloads Sub SetValue( _ ByVal Name As String, _ ByVal Value As String, _ ByVal ParentKeyType As Ferrysoft.Registry.ParentKeyType, _ ByVal SubKey As String) C# internal void SetValue( string Name, string Value) internal void SetValue( string Name, string Value, Ferrysoft.Registry.ParentKeyType ParentKeyType) internal void SetValue( string Name, string Value, Ferrysoft.Registry.ParentKeyType ParentKeyType, string SubKey) Parameters
DeleteValue methods Syntax Visual Basic Friend Overloads Sub DeleteValue( _ ByVal Name As String) Friend Overloads Sub DeleteValue( _ ByVal Name As String, _ ByVal ParentKeyType As Ferrysoft.Registry.ParentKeyType) Friend Overloads Sub DeleteValue( _ ByVal Name As String, _ ByVal ParentKeyType As Ferrysoft.Registry.ParentKeyType, _ ByVal SubKey As String) C# internal void DeleteValue( string Name) internal void DeleteValue( string Name, Ferrysoft.Registry.ParentKeyType ParentKeyType) internal void DeleteValue( string Name, Ferrysoft.Registry.ParentKeyType ParentKeyType, string SubKey) Parameters
DeleteSubKey methods Syntax Visual Basic Friend Overloads Sub DeleteSubKey() Friend Overloads Sub DeleteSubKey( _ ByVal ParentKeyType As Ferrysoft.Registry.ParentKeyType) Friend Overloads Sub DeleteSubKey( _ ByVal ParentKeyType As Ferrysoft.Registry.ParentKeyType, _ ByVal SubKey As String) C# internal void DeleteSubKey() internal void DeleteSubKey( Ferrysoft.Registry.ParentKeyType ParentKeyType) internal void DeleteSubKey( Ferrysoft.Registry.ParentKeyType ParentKeyType, string SubKey) Parameters
DeleteSubKeyTree methods Syntax Visual Basic Friend Overloads Sub DeleteSubKeyTree() Friend Overloads Sub DeleteSubKeyTree( _ ByVal ParentKeyType As Ferrysoft.Registry.ParentKeyType) Friend Overloads Sub DeleteSubKeyTree( _ ByVal ParentKeyType As Ferrysoft.Registry.ParentKeyType, _ ByVal SubKey As String) C# internal void DeleteSubKeyTree() internal void DeleteSubKeyTree( Ferrysoft.Registry.ParentKeyType ParentKeyType) internal void DeleteSubKeyTree( Ferrysoft.Registry.ParentKeyType ParentKeyType, string SubKey) Parameters
Example Use The code below shows an example of how to use the Registry class. To take advantage of the automatic setting of the DefaultSubKey property in the New constructor, the assembly attributes must be set in the AssemblyInfo.vb (for Visual Basic development) or the AssemblyInfo.cs (for C# development) file. Below is an example of an AssemblyInfo.vb file and an AssemblyInfo.cs file with assembly attributes set for Company, Product and Version. Visual Basic
<Assembly: _
System.Reflection.AssemblyCompany("Ferrysoft")>
<Assembly: _
System.Reflection.AssemblyProduct("Ferrysoft Help Desk")>
<Assembly: _
System.Reflection.AssemblyVersion("1.0.0.0")>
C#
[assembly:
System.Reflection.AssemblyCompany("Ferrysoft")]
[assembly:
System.Reflection.AssemblyProduct("Ferrysoft Help Desk")]
[assembly:
System.Reflection.AssemblyVersion("1.0.0.0")]
The code below shows an example of how to use the Registry class. Visual Basic ' ' This example creates a new Registry object ' specifying a DefaultParentKeyType of ' LocalMachine and a DefaultSubKey format of ' Software\Company\Product\Version. ' ' It then displays the DefaultSubKey property ' to demonstrate that the assembly attributes ' have been used to construct the DefaultSubKey ' string correctly. ' ' It then creates an entry named Test containing ' a test value, retrieves the value to prove that ' it has been created successfully and then deletes ' the named value. ' ' Finally it attempts to retrieve the named value. ' This time the attempt fails because the value ' has been deleted. The result is that the default ' value is returned and displayed instead. ' Dim Registry As Ferrysoft.Registry Registry = New Ferrysoft.Registry( _ Ferrysoft.Registry.ParentKeyType.LocalMachine, _ Ferrysoft.Registry.SubKeyType. _ SoftwareCompanyProductVersion) System.Console.WriteLine(Registry.DefaultSubKey) Registry.SetValue("Test", "Test Value") System.Console.WriteLine(Registry.GetValue("Test")) Registry.DeleteValue("Test") System.Console.WriteLine(Registry.GetValue("Test", _ "Default Value")) C# // // This example creates a new Registry object // specifying a DefaultParentKeyType of // LocalMachine and a DefaultSubKey format of // Software\Company\Product\Version. // // It then displays the DefaultSubKey property // to demonstrate that the assembly attributes // have been used to construct the DefaultSubKey // string correctly. // // It then creates an entry named Test containing // a test value, retrieves the value to prove that // it has been created successfully and then deletes // the named value. // // Finally it attempts to retrieve the named value. // This time the attempt fails because the value // has been deleted. The result is that the default // value is returned and displayed instead. // Ferrysoft.Registry Registry; Registry = new Ferrysoft.Registry( Ferrysoft.Registry.ParentKeyType.LocalMachine, Ferrysoft.Registry.SubKeyType. SoftwareCompanyProductVersion); System.Console.WriteLine(Registry.DefaultSubKey); Registry.SetValue("Test", "Test Value"); System.Console.WriteLine(Registry.GetValue("Test")); Registry.DeleteValue("Test"); System.Console.WriteLine(Registry.GetValue("Test", "Default Value")); When the above code is run it produces the following output: Software\Ferrysoft\Ferrysoft Help Desk\1.0 Test Value Default Value |
||||||||||||||||||||||||||||||||||||||||||||||
| Copyright © 2004-2008 Ferrysoft Limited. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||