Hello Coders

Could someone please tell me how to delete a Key Value in the Windows Registry. See the Example, If i take
out the \url2 it will delete the WHOLE KEY, but i am only trying to delete a single key value Name and it string
and it don't work.

I tried /url2 ... //url2 ... \url2 ... \\url2 ... \(Default) and nothing work.

Also How would you also delete the (Default) Value but not the Word (Default) or how to do it both ways by Deleting
all than rewriting the work (Default) with it new Value. ( but i be happy just to do the above anyway with-out all
of this fancy stuff )

Thanks in Advance

PS: If you test this create a key to test on so you don't loss your url2 key just in case it deside
to work.


; #################################################

.486
.model flat, stdcall
option casemap :none

; #################################################
include \masm32\include\windows.inc

include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\advapi32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\advapi32.lib

; #################################################
.data

szKeyName_URL_Default db "Software\Microsoft\Internet Explorer\TypedURL\(Default)",0

szKeyName_URL_1 db "Software\Microsoft\Internet Explorer\TypedURL\url1",0

szKeyName_URL_2 db "Software\Microsoft\Internet Explorer\TypedURL\url2",0


; #################################################

.code

start:

PUSH offset szKeyName_URL_2
PUSH HKEY_CURRENT_USER
CALL RegDeleteKeyA

invoke ExitProcess,eax

end start
Posted on 2002-12-18 18:11:59 by cmax
The RegDeleteValue function removes a named value from the specified registry key. 


LONG RegDeleteValue (
HKEY hKey, // handle of key
LPCTSTR lpValueName // address of value name
);

something like that ?

cyaz,
MerlinDMC
Posted on 2002-12-18 18:41:40 by MerlinDMC
Thanks MerlinDMC,

I tried

PUSH offset szKeyName_URL_2
PUSH HKEY_CURRENT_USER
CALL RegDeleteValue

But it still did not work. I think i tried it in the past before but never had sucess. It seem to be right and that's what
the api help file say to do but it don't work. I am now wondering if it is a bad API for ASM. Have any one ever had success
with this written in ASM.
Posted on 2002-12-18 19:39:09 by cmax
Anything you want to do to a key or value (add/ delete value, add/delete key) in the Registry, you have to open that key first with RegCreateKeyEx or RegOpenKeyEx.

So, to delete the key you want to delete do:

MASM Syntax:
;Open key with RegCreateKeyEx:
;lpSubKey BYTE "Software\Microsoft\Internet Explorer\TypedURL", 0
;hRegKey DWORD ? ; variable that receives the handle to our newly opend key.
;lpValueName BYTE "url1", 0
invoke RegOpenKeyEx, HKEY_CURRENT_USER, addr lpSubKey, NULL, KEY_SET_VALUE, addr hRegKey
.if eax == ERROR_SUCCESS
invoke RegDeleteValue, hRegKey, addr lpValueName
.if eax == ERROR_SUCCESS
;would ya look at that, cmax delete a registry value!!! woooohoooo :cool:
.else
;couldn't delete the value, either the value wasn't there or the user didn't have the correct permissions to delete keys!
.endif
; close the key when done cmax....
invoke RegCloseKey, hRegKey

.else
;ooops error opening key, do something about it will ya!
.endif

oops, almost forgot, you can pass an empty string or NULL for the lpValueName to RegDeleteValue to delete the "default" value of a key.
hope this helps ya cmax! You should open the key and enum the values, as you get the value names in the key, delete them.
Posted on 2002-12-18 21:18:14 by Gunner
I did a program for a slightly different value in the registry. Be careful. It works.
This program deletes any url value in:
HKEY_USERS\{coded key}\Software\Microsoft\Internet Explorer\TypedURLs
as opposed to:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURL
It enumerates a coded value that should be different on each computer.
It is for Windows 2000. Notice the last key ends with an s too.
It asks with an annoying messagebox that goes to the background
before it deletes, and it does delete.
Posted on 2002-12-18 22:00:45 by roaknog
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURL


You guys wanna remove items in the typedurl to remove trails of pr*n? :grin:
Posted on 2002-12-18 22:13:08 by roticv
Gunnerrrrrrr

it Working

For me it only goes to prove that it SOMETIMES takes more than the small instrutions that you may find in the API help files. You got to have an creative mind to add the extra needed things when those instrustion fails, because i'm sure i did everything right acording to the API instructions and would have never thought to add more.

So Thanks, Next time i go in with my GUNS fully LOADED...

roaknog, I did not get your example to work yet, but i will soon. (Got too excited with Gunners Wrap and Code. Did you know that ypur example makes it easy for someone who don't have a clue about concoles this program
makes it all so easy to understand. It's a great lead to undersrtanding Drivers that you have written.

Btw, i know you are a near device master,how about RING 0 in 2000 and XP :)

Thanks roaknog
Posted on 2002-12-19 01:38:11 by cmax
cmax:
... yep ... it doesn't work ...

gunner has given the correct example ...
I had no time yesterday to type such an example :(

Gunner:
pssst ... not that loud ! :grin:

cyaz,
MerlinDMC
Posted on 2002-12-19 01:39:47 by MerlinDMC
If you change:
sub_key DB '\Software\Microsoft\Internet Explorer\TypedURLs', 0
to:
sub_key DB '\Microsoft\Internet Explorer\TypedURL', 0

and the 2 instances of HKEY_USERS to HKEY_CURRENT_USER in my program

you get the bloated equivalent of what you want. The program finds '\Software' on its own as long as your url2 exists, but I don't have that sub key on my computer. I had to add it by hand.
Posted on 2002-12-19 10:37:54 by roaknog
Merlin, I was under heavy influence of NyQuil when I replyed to that, so I was not loud :grin:

cmax, no problem, I have done extensive work with the registry (in VB) but I have found it to be easier in assembly, so if you have anymore questions about the registry, just give me a hollar!
Posted on 2002-12-19 18:02:30 by Gunner