home *** CD-ROM | disk | FTP | other *** search
-
- E A S Y R E G I S T R Y
- January 1998
-
-
- O.S. : Windows 95, Windows NT
- Language : Visual Basic 5.0 (SP3)
- EASYREGISTRY.DLL Ver. 2.0.3
- ActiveX Component
- GlobalMultiuse
- Multithread
-
-
- 1. Introduction
- 2. Navigate Registry Keys
- 3. Obtain Registry Keys listing
- 4. Obtain Registry Values Names listing
- 5. Manipulate Registry Values
- 6. Manipulate Registry Keys
- 7. Limitations
- 8. Support
-
-
- -----------------
- 1. Introduction
- -----------------
-
- Are you looking for an EASY way to access System Registry ?
- System Registry is a hierarchically structured tree. Each node in the tree is
- called a KEY. Each key can contain both subkeys and data entries called
- VALUES.
- You can navigate the registry as DOS-like commands let you navigate
- directories.
-
- You need to register EasyRegistry.DLL with REGSVR32.EXE and then in your VB
- program you have to add a reference to the DLL.
-
- In EasyRegistry there are costants defined to make code more legible and
- public Enum are defined to help coding.
- Constant start with er... i.e. erByte.
-
- --------------------------
- 2. Navigate Registry Keys
- --------------------------
-
- Use CD method to navigate registry tree :
- - CD "\"
- set the root as the current key.
- - CD "<subkey name>"
- subkey <subkey name> (of the current key) became the current key.
- - CD "\<key 1 name>\<key 2 name>\...\<key n name>"
- give a complete path to set the current key.
- - CD ".."
- Move up one level the current key.
-
- So
-
- Dim Reg As New clsEasyRegistry
- Reg.Cd "\HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\WINDOWS"
- Reg.Cd ".."
- Debug.Print Reg.CurrentKey
-
- is the same of
-
- Dim Reg As New clsEasyRegistry
- Reg.Cd "\"
- Reg.Cd "HKEY_CURRENT_USER"
- Reg.Cd "SOFTWARE"
- Reg.Cd "MICROSOFT"
- Debug.Print Reg.CurrentKey
-
-
- --------------------------------
- 3. Obtain Registry Keys listing
- --------------------------------
-
- DirKey function return a variant.
- It is Null if the current key has not any subkey.
- Otherwise it is an array of strings containing subkeys names.
-
- Dim Reg As New clsEasyRegistry
- Dim astrResult As Variant
- Dim lngJ As Long
- Debug.Print Reg.CurrentKey
- astrResult = Reg.DirKey
- If Not IsNull(astrResult) Then
- For lngJ = LBound(astrResult) To UBound(astrResult)
- Debug.Print astrResult(lngJ)
- Next
- End If
- Reg.Cd astrResult(LBound(astrResult))
- Debug.Print Reg.CurrentKey
-
-
- ----------------------------------------
- 4. Obtain Registry Values Names listing
- ----------------------------------------
-
- DirValue function return a variant.
- It is Null if the current key has not any value.
- Otherwise it is an array of strings containing values name, values type and
- values in the current key.
-
- Dim Reg As New clsEasyRegistry
- Dim astrResult As Variant
- Dim lngJ As Long
- Reg.Cd "\HKEY_CURRENT_USER\INSTALLLOCATIONSMRU"
- astrResult = Reg.DirValue
- If Not IsNull(astrResult) Then
- For lngJ = LBound(astrResult, 2) To UBound(astrResult, 2)
- Debug.Print "Value Name : " & astrResult(erValueName, lngJ)
- Select Case astrResult(erValueType, lngJ)
- Case erByte
- Debug.Print "Value Type : " & "Byte"
- Case erSTRING
- Debug.Print "Value Type : " & "String"
- Case erDWord
- Debug.Print "Value Type : " & "DWord"
- End Select
- Debug.Print "Value : " & astrResult(erValue, lngJ)
- Debug.Print
- Next
- End If
-
- Value type can be STRING, BYTE or DWORD.
-
-
- ------------------------------
- 5. Manipulate Registry Values
- ------------------------------
-
- ValueOf property set (and create) or get a value in the current key.
- DeleteValue method remove an existing value from the current key.
-
-
- - ValueOf(<Value Name>,<Value Type>) = <Value>
- SET a value in the current key.
-
- <Value Name> is a string with the name of value in the current key (IN),
- <Value Type> is a long, can be set to erSTRING, erBYTE or erDWORD (IN),
- <Value> is the value <Value Name> of type <Value Type> (IN).
- If <Value Type> is erSTRING, then <Value> is a STRING,
- if <Value Type> is erBYTE then <Value> is an array of BYTEs,
- If <Value Type> is erDWORD then <Value> is a rounded DOUBLE (0..4294967295).
- N.B. if <Value Name> is not present in the current key it will be added.
-
- Dim Reg As New clsEasyRegistry
- Dim abytBYTE(0 To 1) As Byte
- Reg.Cd "\HKEY_CURRENT_USER\SOFTWARE\VB AND VBA PROGRAM SETTINGS"
- Reg.ValueOf("NewValueName 1", erSTRING) = "Hello World !"
- Reg.ValueOf("NewValueName 2", erDWord) = 666666666#
- abytBYTE(1) = 100
- abytBYTE(0) = 255
- Reg.ValueOf("NewValueName 3", erByte) = abytBYTE
-
-
- - avntVariable = ValueOf(<Value Name>,<Value Type>)
- GET a value in the current key.
-
- <Value Name> is a string with the name of value in the current key (IN),
- <Value Type> is a long, can be erSTRING, erByte or erDWord (OUT),
- avntVariable is an array of variant value returned (OUT),
- avntVariable(erStringFormat) is a formatted STRING,
- avntVariable(erByteFormat) is an array of BYTEs,
- avntVariable(erDWordFormat) is a rounded DOUBLE.
-
- Dim Reg As New clsEasyRegistry
- Dim avntVariable As Variant
- Dim lngType As enmDataType
- Dim lngJ As Long
- Reg.Cd "\HKEY_CURRENT_USER\SOFTWARE\VB AND VBA PROGRAM SETTINGS"
- Reg.ValueOf("NewValueName 4", erDWord) = 4294967295#
- avntVariable = Reg.ValueOf("NewValueName 4", lngType)
- Select Case lngType
- Case erByte
- Debug.Print "Type : " & "Byte"
- Case erSTRING
- Debug.Print "Type : " & "String"
- Case erDWord
- Debug.Print "Type : " & "DWord"
- End Select
- Debug.Print "Value : " & avntVariable(erDWordFormat)
- Debug.Print "Value (Hex) : " & avntVariable(erStringFormat)
- Debug.Print "Value (Bytes) : "
- For lngJ = LBound(avntVariable(erByteFormat)) To UBound(avntVariable(erByteFormat))
- Debug.Print avntVariable(erByteFormat)(lngJ);
- Next
- Debug.Print
-
-
- - DeleteValue <Value Name>
- <Value Name> is a string with the name of value in the current key.
-
- Dim Reg As New clsEasyRegistry
- Reg.Cd "\HKEY_CURRENT_USER\SOFTWARE\VB AND VBA PROGRAM SETTINGS"
- Reg.ValueOf("Temp Login Time",erSTRING) = "12:12.55"
- Reg.DeleteValue "Temp Login Time"
-
-
- ----------------------------
- 6. Manipulate Registry Keys
- ----------------------------
-
- MakeKey method add a new subkey in the current key.
- DeleteKey method delete an existing subkey in the current key.
- CurrentKey property return the current key.
-
- Dim Reg As New clsEasyRegistry
- Reg.MakeKey "Friends"
- Reg.CD "Friends"
- Debug.Print Reg.CurrentKey
- Reg.MakeKey "Bimbo Gigi"
- Reg.CD ".."
- Reg.DeleteKey "Friends"
-
- N.B.In Windows 95 DeleteKey recursively delete all subkeys of the current key,
- in Windows NT DeleteKey can't delete a key that has subkeys.
-
-
- ----------------
- 7. Limitations
- ----------------
-
- If you find any bug or improvements to EasyRegistry please tell me,
- that's why I'm sharing my work.
-
- Only STRING, BYTE and DWORD values type are supported, anyway different data
- types can be stored in the registry.
- So EasyRegistry can't be useful to write a REGEDIT-like application, you can
- use it with application that access well defined data types in the registry.
-
-
- -----------
- 8. Support
- -----------
-
- If you discover any bug or improvements to EasyRegistry please tell me,
- that's why I'm sharing my work.
- I'll correct any bug as soon as possible.
- Suggestions are welcome.
-
- When EasyRegistry will be enough stable and error-free I'll release source
- code to anyone will make request of it.
-
- For any message about EasyRegistry e-mail me specifying "EASYREGISTRY" in the
- subject.
- ___________________________________________________
- Luca Minudel software designer
- Italy Conegliano (TV)
- voice & fax +39 (0)438 412280
- e-mail luca.minudel@nline.it
- WWW (italian language used)
- http://www.geocities.com/SiliconValley/Vista/4041
-
-