Click here to Skip to main content
13,794,213 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


11 bookmarked
Posted 20 Oct 2017
Licenced CPOL

DLL Registry Control Easier

, 6 Oct 2018
Rate this:
Please Sign up or sign in to vote.
A simple library to control registry easier


A simple library to control the registry more easily than using the basic methods proposed by the .NET Framework.


The following DLL simplifies the basic method. A single command per operation and the DLL checks if the key or registry value exists, then applies the command requested and closes the key. The DLL handles errors and logs in a file.

Using the Code

How to correctly delete a SubKey by .NET Framework solution:

Dim Key As RegistryKey
  Key = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Test", False)
  If Key Is Nothing Then 'if key exist
      MsgBox("key doesn't exist")
      Exit Sub
      Key = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run\", True)
  End If

And by this DLL:

Reg_DeleteSubKey("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\MyNewSubKey", "Test")

Points of Interest

If a SubKey or Value doesn't exist, DLL returns "0/False". If an error occurs, a specify messagebox appears.


     Key.DeleteValue(BV_ValueName, True)
     Return "True"
Catch ex As Exception
     MsgBox(ex.Message & vbNewLine & BV_TreeKeyName & vbNewLine & "BV_DeleteValue", 
            MsgBoxStyle.Critical, "BV_DeleteValue")
     LogInFile(ex.Message & vbNewLine & BV_TreeKeyName & vbNewLine & "BV_DeleteValue")
     Return ex.Message & vbNewLine & BV_TreeKeyName & vbNewLine & "BV_DeleteValue"
End Try

All functions begin with "Reg_". Do not use the following functions:

  • ValueTypeLong
  • MasterFunction
  • ExistKeyOrValue

These three functions are called by the commands "Reg_" or "RegF_".


The source of the DLL is fully commented in English and French.

The DLL simplifies the most common standard commands. It does not, for example, manage permissions (ACLs). But if you have solutions to improve, do not hesitate to post in the comments or send me a private message.

The operation is very simple, to fully understand, I added a source that uses all functions. For the example in the source, messagebox is used but in standard use, do not use messagebox.

Name of Functions

Reg_KeyExist Function to test, if a SubKey exists  
Reg_ValueExist Function to test, if a Value exists
Reg_SetOrCreateValue Function for create, edit or set a value
Reg_CreateSubKey Function for create a subkey
Reg_GetDataValue Function to get the data of a value
Reg_GetListValueName Function to get a List (array) of Values
Reg_GetValueKind Function to get the Kind of a Value
Reg_GetSubKeyNames Function to get a List (array) of SubKeyName
Reg_DeleteValue Function to delete a Value
Reg_DeleteSubKey Function to delete a SubKey recursively or not

Function to get the short name of Tree (example HKEY_LOCAL_MACHINE --> HKLM)


Function to copy a Value to another Value by copying its name, data and type If the destination value does not exist, it is created, if it exists, it is replaced)

RegF_ConvertStringDefaultInBinary / RegF_ConvertStringASCIIInBinary / RegF_ConvertStringUtf8InBinary

Convert String Utf8/Ascii/Default in Binary

Example : Dim InByte As Byte() = RegF_ConvertStringASCIIInBinary(MyStringToConvert))


The following is a list of changes available in version of this library.

  • Bugfix : Possibility to write in root keys
  • Copy a value to another value
  • Convert a string to a binary type


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

France France
No Biography provided

You may also be interested in...


Comments and Discussions

BugSecond download missing? Pin
Tokinabo29-Dec-17 4:50
professionalTokinabo29-Dec-17 4:50 
GeneralRe: Second download missing? Pin
DX901-Apr-18 7:09
memberDX901-Apr-18 7:09 
GeneralMy vote of 5 Pin
Tokinabo29-Dec-17 4:45
professionalTokinabo29-Dec-17 4:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.181207.3 | Last Updated 7 Oct 2018
Article Copyright 2017 by DX90
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid