Hello

Can you tell me how to delete a value in windows registry, thanx

euh, i use windows xp, i was doing
keyToKick db "SOFTWARE\value1\value2",0

invoke RegDeleteValue,HKEY_LOCAL_MACHINE,ADDR keyToKick

as indicated api's manuel, but it doesn't work :(

so please help me :)
Posted on 2002-01-26 15:46:36 by ZeuX
RegDeleteKeyA PROTO :DWORD,:DWORD
RegDeleteValueA PROTO :DWORD,:DWORD

Posted on 2002-01-26 16:20:29 by cmax
you code appears to be right, you must be overlooking something.


keyToKick db "SOFTWARE\value1\value2",0

looking at this line of code here im wondering if you problem is here. ok i know SOFTWARE is a key but is value1 and value2 a key? or is value1 key and value2 is a value for sure?

just make sure your using the right one of these:

RegDeleteValue
RegDeleteKey
Posted on 2002-01-26 20:09:07 by smurf
How about if you RegCreateKeyA or RegOpenKeyA to get a handle of the key you wish to delete?
btw your code doesnt appear correct at all (no offnese it was directed at one of the replys)
Try regcreatekey and im sure it will all be sorted out :)
good luck

LONG RegDeleteKey(
HKEY hKey, // handle of open key
LPCTSTR lpSubKey // address of name of subkey to delete
);
Posted on 2002-01-26 20:50:58 by Noodle
ya i was wrong. i thought you wouldnt have to open up the key because i thought you could use one of the predefined reserved handle values but thats not the case.

so your code should look like this:


.data
keyToOpen db "SOFTWARE\value1\",0
valueToKick db "value2",0

.data?
hOpenKey HANDLE ?

.code
invoke RegOpenKeyEx,HKEY_LOCAL_MACHINE,ADDR keyToOpen,0,KEY_ALL_ACCESS,addr hOpenKey
invoke RegDeleteValue,hOpenKey,addr valueToKick
invoke RegCloseKey,hOpenKey
Posted on 2002-01-26 21:24:01 by smurf
Of course, a key may contain a subkey, and any subkeys must first be deleted.

This may help there:



GuardedDeleteKey PROC hKey:DWORD, lpszSubKey:DWORD
LOCAL szSubKeyName [MAX_PATH+1]:TCHAR
LOCAL hSubkey :DWORD

; check to see if the key to be deleted still has subkey,
; if not delete it, otherwise delete the subkey
invoke RegOpenKey, hKey, lpszSubKey, ADDR hSubkey
.IF (eax != ERROR_SUCCESS)
mov eax, REGDB_E_INVALIDVALUE
jmp return
.ENDIF
KillNextSubkey:
; check for a subkey
invoke RegEnumKey, hSubkey, 0, ADDR szSubKeyName, MAX_PATH+1
.IF (eax != ERROR_NO_MORE_ITEMS) ; IF SubKeys exist...
; delete the subkey thru recusion
invoke GuardedDeleteKey, hSubkey, ADDR szSubKeyName
jmp KillNextSubkey
.ELSE
.ENDIF
; no more Subkeys, delete the specfied hey.
invoke RegCloseKey, hSubkey
invoke RegDeleteKey, hKey, lpszSubKey
.IF (eax == ERROR_SUCCESS)
xor eax, eax ; mov eax, S_OK
.ENDIF
return:
ret
GuardedDeleteKey ENDP


Just be careful and don't hand this proc something like HKEY_LOCAL_MACHINE or it will quite happily rip it all out.
Posted on 2002-01-27 01:11:11 by Ernie