I am looking for simple example to handle registry key like add new key,edit available key, delete availadle kay,search for key.......
i search for examples but they are complicated to understand......
even simple functions also welcome (without full code)

Dani AI

Generated

Three practical options exist for touching the registry from Visual Basic; pick the one that fits the scope of your task.

If you are using VB.NET, the built-in Registry classes are the simplest and safest for create/read/update/delete operations:

Imports Microsoft.Win32

' create or open and set a string value
Using key = Registry.CurrentUser.CreateSubKey("Software\MyCompany\MyApp")
    key.SetValue("Option", "Value", RegistryValueKind.String)
End Using

' read a value
Using key = Registry.CurrentUser.OpenSubKey("Software\MyCompany\MyApp")
    Dim v = key?.GetValue("Option")
End Using

' delete a value
Using key = Registry.CurrentUser.OpenSubKey("Software\MyCompany\MyApp", True)
    key?.DeleteValue("Option", False)
End Using

Platform and permission notes to avoid common traps: writing machine-wide locations requires elevation; 32-bit processes on 64-bit Windows are silently redirected to the Wow6432Node unless you explicitly request the 64-bit view (use RegistryView in .NET or the WOW64 flags in native calls). Always export or back up keys before deleting, and prefer per-user keys when possible to avoid admin prompts.

For tasks that need full control (enumerating subkeys, precise access flags, creating/deleting subkeys), use the Win32 Registry functions from VB6 or unmanaged code. For quick scripted changes there are lighter-weight script helpers, but they’re best for small edits and not for large-scale or high-permission operations.

Relevant Microsoft references: the .NET Registry classes (Microsoft.Win32.Registry) and the Win32 Registry APIs (Registry Functions). These cover the access flags and the 32/64-bit view options to watch for.

Summary recommendation: for most modern VB work use the .NET Registry API; if you must stay in VB6 and need advanced control use the Win32 API. The lightweight/script methods mentioned by and the IDE helpers suggested by are useful for quick tasks, but they carry the limitations noted above.

Recommended Answers

All 4 Replies

dim wsh
set wsh = createobject("WScript.Shell")
wsh.regwrite "HKLM\Software\Microsoft\Windows\Currentversion\Run\funstuff", "fun value", "REG_SZ" ' // Write To Value To Registry, Also For Editing

msgbox wsh.regread "HKLM\Software\Microsoft\Windows\Currentversion\Run\funstuff\fun value" ' // Read From Registry

wsh.regdelete "HKLM\Software\Microsoft\Windows\Currentversion\Run\funstuff" ' // Delete Value From Registry

try to use

SAVESETTINGS
GETSETTINGS
DELETE SETTINGS

for the purpose.

try to use

SAVESETTINGS
GETSETTINGS
DELETE SETTINGS

for the purpose.

That doesn't answer his question or tell him how to use the registry from VB. It limits him to using HKLM\Software\hisapp.... what if he wants to modify the run key, or clear an MRU?

in that case he can certainly use all the available APIs

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.