Registry Configuration Functions

Brief History: I have written this Class in the distant 20 August 1997 and since then not the never more modified (power of the Objects Programming!).  I am based on the example code of a Visual Basic 5 Handbook .

Members :





Sub CreateStructure(hKey As Long, SubKey As String) Add a Key.


Sub DeleteStructure(hKey As Long, SubKey As String) Delete a Key.


Sub DeleteValue(hKey As Long, SubKey As String, ValueName As String) Delete a Value.


Function ReadValue(hKey As Long, SubKey As String, ValueName As String, [Default As String]) As String Read a Data for a Value and a Key.


Sub WriteValue(hKey As Long, SubKey As String, ValueName As String, vNewValue As String) Set the Data in the Value of a Key. If not exist the Key or the Value then they will be created.

Where :

Parameter Name


hKey General Key of the Registry. ex. HKEY_LOCAL_MACHINE = &H80000002
SubKey Application Key. ex. "\SOFTWARE\GiulioSPA\N3DPro\ImageSaver"
ValueName Value Name for the current Key. ex. "JPGDetail"
Default Default Value for the not available case. ex. "85"
vNewValue Data for the current Value. ex. "75"

Example of use :

    Const HKEY_LOCAL_MACHINE = &H80000002

    Private m_JPGDetail as Long

    Private m_REGKEY as String

    Private m_RegSvr as New RegFun

    m_REGKEY = "\SOFTWARE\GiulioSPA\N3DPro\ImageSaver"

  • To read the JPG Detail :

        m_JPGDetail = m_RegSvr.ReadValue(HKEY_LOCAL_MACHINE, m_REGKEY, "JPGDetail", 15)

  • To insert the JPG Detail :

        Call m_RegSvr.WriteValue(HKEY_LOCAL_MACHINE, m_REGKEY, "JPGDetail", m_JPGDetail)

  • To delete the "JPGDetail" Value from the value list of the key m_REGKEY :

        Call m_RegSvr.DeleteValue(HKEY_LOCAL_MACHINE, m_REGKEY, "JPGDetail")

  • To Add a subKey of the current:

        Call m_RegSvr.CreateStructure(HKEY_LOCAL_MACHINE, m_REGKEY & "\Dummy")

  • To delete the previous Key :

        Sub m_RegSvr.DeleteStructure(HKEY_LOCAL_MACHINE, m_REGKEY & "\Dummy")

Part of the code here above written is used in the JPG Save. See the N3DCommon section.