News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Deleting a Registry Setting

Started by Ash_, September 05, 2005, 01:29:43 PM

Previous topic - Next topic

Ash_

so far i've got.

DeleteString proc lpszKey:DWORD
LOCAL phkResult :DWORD

invoke RegOpenKeyEx,HKEY_LOCAL_MACHINE,lpszKey,0,KEY_ALL_ACCESS,ADDR phkResult

invoke RegCloseKey,phkResult
xor eax,eax
DeleteString endp


but my program always errors

im calling it like.


invoke DeleteString, addr szAllKey



szAllKey    DB  "test",0


the folder is there in regedit.exe so it must work.
can you gelp me at all?

czDrillard

Use RegDeleteKey to delete keys and and RegDeleteValue to delete key values.  Remember the sub key you are deleting can't have any subkeys and the key must be opened with DELETE access rights.

best regards,

czDrillard

Mark Jones

Here is a small registry-key related app. DeleteKey is similar. See the win32api.hlp


; Mark Jones/Helios Studios 2005
; build as "console assemble and link"
include masm32rt.inc    ; "compile-time" libs
include advapi32.inc    ; registry functions
includelib advapi32.lib

.data
    szKey       DB  "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\",0
    szValue     DB  "GlobalMaxTcpWindowSize",0

.data?
    buff        DD  ?
    buffsize    DD  ?
    hKey        DD  ?
    keyType     DD  ?

.code
start:
    print chr$("GlobalMaxTcpWindowSize: ")
   
    invoke RegOpenKeyEx,HKEY_LOCAL_MACHINE,addr szKey,0,KEY_QUERY_VALUE,addr hKey
    test eax,eax                ; does the key exist?
    jnz nokey
    mov buffsize,4
    invoke RegQueryValueEx,hKey,addr szValue,0,addr keyType,addr buff,addr buffsize
    test eax,eax                ; is there a GlobalMaxTcpWindowSize value?
    jz valfound
    print chr$("value not present.")
    jmp endit
nokey:
    print chr$("key not present!")
    jmp endit
valfound:
    print ustr$(buff)
endit:
    Invoke RegCloseKey,hKey     ; close key
    mov eax, input(13,10,13,10,"Press enter to exit:")
    invoke ExitProcess, 0       ; exit gracefully
end start
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08