It is in HKEY_USERS
The path is "\.DEFAULT\Software\Microsoft\Windows\Run"
and the value for the key is "Choke"
So it's:
HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\Run\Choke
How can I get rid of this value using RegDeleteValue with code?
Printable View
It is in HKEY_USERS
The path is "\.DEFAULT\Software\Microsoft\Windows\Run"
and the value for the key is "Choke"
So it's:
HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\Run\Choke
How can I get rid of this value using RegDeleteValue with code?
Like so:
In a Module:Usage:Code:Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_USERS = &H80000003
Private Const KEY_CREATE_LINK = &H20
Private Const KEY_CREATE_SUB_KEY = &H4
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_EVENT = &H1
Private Const KEY_NOTIFY = &H10
Private Const KEY_QUERY_VALUE = &H1
Private Const KEY_SET_VALUE = &H2
Private Const SYNCHRONIZE = &H100000
Private Const STANDARD_RIGHTS_ALL = &H1F0000
Private Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Public Enum enumHive
CLASSES_ROOT = HKEY_CLASSES_ROOT
LOCAL_MACHINE = HKEY_LOCAL_MACHINE
CURRENT_USER = HKEY_CURRENT_USER
USERS = HKEY_USERS
End Enum
Public Function DeleteRegValue(ByVal sKey As String, ByVal sValue As String, Optional ByVal lHive As enumHive = LOCAL_MACHINE) As Boolean
Dim lRegKey As Long
' Open the Key containing the value to delete
If RegOpenKeyEx(lHive, sKey, 0&, KEY_ALL_ACCESS, lRegKey) = 0 Then
' If opened (it existed and we have rights to do anything we want to it)
' Delete the specified value...
DeleteRegValue = (RegDeleteValue(lRegKey, sValue) = 0)
' Close the container key
Call RegCloseKey(lRegKey)
End If
End Function
Code:Private Sub Command1_Click()
If DeleteRegValue(".Default\Software\Microsoft\Windows\CurrentVersion\Run", "Choke", USERS) Then
MsgBox "Value Deleted."
End If
End Sub