when i use invoke RegOpenKeyEx, HKEY_LOCAL_MACHINE...
how come i cant do it like this ..
Hive db "HKEY_LOCAL_MACHINE",2 dup(0)
invoke RegOpenKeyEx, addr Hive
:confused:
how come i cant do it like this ..
Hive db "HKEY_LOCAL_MACHINE",2 dup(0)
invoke RegOpenKeyEx, addr Hive
:confused:
Hello ill will,
The first param expects a "reg key handle" instead of ASCIIZ string.
HKEY_LOCAL_MACHINE is a constant that RegOpenKeyEx recognises as one of the root handles.
The first param expects a "reg key handle" instead of ASCIIZ string.
HKEY_LOCAL_MACHINE is a constant that RegOpenKeyEx recognises as one of the root handles.
is there anyway to get around it? i wanna be able to pass HKLM and HKCU depending on what key i need to pull from the registry
Yes, pass either HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE as the first param, meaning you're going to open a subkey under either HKCU or HKLM, respectively.
yea but can i use the Hive db method?? i wanna be able to change it that way ... is there a non ascii way of interchanging it instead of putting HKEY_LOCAL_MACHINE as the first param i want my program to place it there as a variable ..
how can i change it back and forth instead of using the HIVE db
how can i change it back and forth instead of using the HIVE db
Nope, you cannot pass a string for the hKey, it has to be a handle to an open key or one of the predefined keys. Cannot pass a address to a string.
What are you trying to do? Let's say you have a combo box and it is filled with:
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
are you trying to pass the selection to RegOpenKeyEx?
Let's say you are, then I would use this code:
and you would pass hHive as the hKey parameter.
What are you trying to do? Let's say you have a combo box and it is filled with:
HKEY_CLASSES_ROOT
HKEY_CURRENT_CONFIG
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USERS
are you trying to pass the selection to RegOpenKeyEx?
Let's say you are, then I would use this code:
push 0
push 0
push CB_GETCURSEL
push ComboHandle
call SendMessage
.if eax == 0
mov hHive, HKEY_CLASSES_ROOT
.elseif eax == 1
mov hHive, HKEY_CURRENT_CONFIG
.elseif eax == 2
mov hHive, HKEY_CURRENT_USER
.elseif eax == 3
mov hHive, HKEY_LOCAL_MACHINE
.elseif eax == 4
mov hHive, HKEY_USERS
.endif
and you would pass hHive as the hKey parameter.
just use
If you are starting out with a string argument from a listbox or something just use a string compare...
Alternatively if you are using a listbox or a listview you can use LB_SETITEMDATA / LB_GETITEMDATA or LVIF_PARAM respectively to set dword values (like the constants) to individual items, so you dont have to worry about the string mess.
.data
Hive dd HKEY_LOCAL_MACHINE
.code
invoke RegOpenKeyEx, Hive... ; open HKLM
mov Hive, HKEY_CURRENT_USER
invoke RegOpenKeyEx, Hive... ; open HKCU
If you are starting out with a string argument from a listbox or something just use a string compare...
.data
szHKLM db "HKEY_LOCAL_MACHINE", 0
szHKCU db "HKEY_CURRENT_USER", 0
Hive dd ?
.code
invoke lstrcmp, addr szHKLM, addr szSelectedInListbox
.if eax == 0
mov Hive, HKEY_LOCAL_MACHINE
.endif
invoke lstrcmp, addr szHKCU, addr szSelectedInListbox
.if eax == 0
mov Hive, HKEY_CURRENT_USER
.endif
invoke RegOpenKeyEx, Hive...
Alternatively if you are using a listbox or a listview you can use LB_SETITEMDATA / LB_GETITEMDATA or LVIF_PARAM respectively to set dword values (like the constants) to individual items, so you dont have to worry about the string mess.