PDA

Click to See Complete Forum and Search --> : Deleting registry strings


digisol1
Nov 5th, 1999, 01:17 PM
I have read about a million posts and I tell you, just about everything is covered. The only thing missing is deleting registry STRINGS. What I am tring to do is first put my app in the .\..\..CurrentVersion\run folder (which has been answered). Then I want to remove it. I know about the runonce key but I will need my program for quit a few reboots. If anyone could give a example as to how I can accomplish this I will be very thankful.

Aaron Young
Nov 5th, 1999, 01:34 PM
You need to use the RegDeleteKey and RegDeleteValue APIs, eg.

To Remove a Value From a Key..

Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002

Private Sub Command1_Click()
Dim lRegKey As Long
Call RegOpenKey(HKEY_LOCAL_MACHINE, "Software\TestKey\", lRegKey)
Call RegDeleteValue(lRegKey, "Test Value")
End Sub

To Delete an Entire Key or Key Structure..

Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey As String) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002

Private Sub Command1_Click()
Call RegDeleteKey(HKEY_LOCAL_MACHINE, "Software\TestKey\")
End Sub



------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

digisol1
Nov 6th, 1999, 04:57 AM
Thank you very much for replying and thank you for such a great board.