Win API RegDeleteKeyValue error

Occasional Visitor



We use RegDeleteKeyValue in our code but since the latest update of Windows we have an issue. The function returns 5 each time we call it in a right case.


Please find the following Office VBA sample code for reproducing the behavior:


Declare PtrSafe Function RegDeleteKeyValue Lib "advapi32.dll" Alias "RegDeleteKeyValueA" (ByVal hKey As LongPtr, ByVal lpSubKey As String, ByVal lpValueName As String) As Long


Global Const HKEY_CURRENT_USER = &H80000001

Global Const HKEY_LOCAL_MACHINE = &H80000002

Global Const HKEY_USERS = &H80000003


Sub RemoveRegKey()

    Dim lResult As Long

    lResult = RegDeleteKeyValue(HKEY_CURRENT_USER, "SOFTWARE\MyProgram\Config", "MyValue")

    Debug.Print lResult

End Sub


Thanks for your help.



0 Replies