The first code created an entry to start netscape and it works fine. I want to be able to delete the reg entry, but the second code section doesn't work.

Thanks.

.data

run_subkey      db "SOFTWARE\Microsoft\Windows\CurrentVersion\Run",0
run_name        db "netscape",0 ; anything can go here
run_path        db "C:\Program Files\Netscape\Netscape\netscp.exe",0

.data?
tmp dd ?


.code

start:

  invoke  RegCreateKeyEx, HKEY_CURRENT_USER, ADDR run_subkey, 0, 0, 0, KEY_WRITE, 0, ADDR tmp, 0
    cmp    eax, ERROR_SUCCESS
    jne    @f
    invoke  RegSetValueEx, , ADDR run_name, 0, REG_SZ, ADDR run_path, sizeof run_path
    invoke  RegCloseKey,

-------------------------------------------------------------------------

.data

szKeyName      BYTE    "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\netscape",0


.code

start:

invoke RegDeleteKey,HKEY_CURRENT_USER,ADDR szKeyName
invoke ExitProcess,NULL
Posted on 2006-07-11 21:04:45 by skywalker
What error code does RegDeleteKey return ? (try GetLastError)
BTW are you sure you closed the handle of the key before trying to delete it ?

EDIT : seems you confused the key and the value. You should use RegDeleteValue
Posted on 2006-07-12 01:42:02 by Axial
You should look at the SHLWAPI for this type of thing, it is much easier to use...

SHDeleteKey
SHGetValue
SHSetValue

Donkey
Posted on 2006-07-12 15:01:45 by donkey
This deletes the entire Run key, but I just want to delete the Run\netscape entry.
I know how to create the key again, but there should be a direct way.

Thanks.

.DATA
                 
SubKey      BYTE "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\",0

Key_Deleted BYTE "Registry key sucessfully deleted.",0
Sample      BYTE "Sample",0 ; title of message box
Problem    BYTE "Registry Key Not Present or Not Deleted !",0

.DATA?

RegH PHKEY ? ; Handle for register key

.CODE

Start:

; Open the key we want to delete

invoke RegDeleteKey,HKEY_CURRENT_USER, ADDR SubKey
Posted on 2006-07-13 11:11:38 by skywalker
Try changing:  SubKey      BYTE "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\",0

To: SubKey      BYTE "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\netscape\",0

Zcoder....
Posted on 2006-07-16 17:29:24 by Zcoder
This is what I found that works.

  .data

sub_key  db "SOFTWARE\Microsoft\Windows\CurrentVersion\Run",0 ; address of null                                                                ; terminated subkey
key_value db "netscape",0                                ; address of value to be deleted

    .code

start:

    invoke SHDeleteValue, HKEY_CURRENT_USER, ADDR sub_key, ADDR key_value
Posted on 2006-07-17 10:52:09 by skywalker