I found this procedure that I am using successfully to add Registry values:




SetRegKeysz PROC lpszString:DWORD, lpszKeyName:DWORD, lpszValueName:DWORD, dwStringLength
LOCAL Disp :DWORD
LOCAL pKey :DWORD
invoke RegCreateKeyEx, HKEY_CURRENT_USER,
lpszKeyName, NULL, NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL,
addr pKey, addr Disp
.IF eax == ERROR_SUCCESS
invoke RegSetValueEx, pKey, lpszValueName,
NULL, REG_SZ,
lpszString, dwStringLength
invoke RegCloseKey, pKey
.ENDIF
ret
SetRegKeysz ENDP



The problem is, I am stuck adding keys to HKEY_CURRENT_USER because it is hard coded.

Currently you call the function like this:




invoke SetRegKeysz , ADDR RegistryTextToAdd, ADDR szKeyNameToAdd, ADDR szStringValueToAdd, SIZEOF szStringValueToAdd




Here is the Prototype for the function:




SetRegKeysz PROTO :DWORD, :DWORD, :DWORD, :DWORD



What I would like to do, is add another parameter so I am not stuck adding values in HKEY_CURRENT_USER.

Is this process involved? If it is, I may as well just write my values in HKEY_CURRENT_USER, as I am sorta new at this.


Could it be as simple as changing adding another :DWORD to the prototype? (at work, no compiler here to test).
If so, would I have to change anything in the Proc itself, like replacing the hard coded value with a variable?

BTW - this board rocks. Glad I found it.

Regards,

Trope
Posted on 2004-11-16 15:10:00 by TropE
i had the same problem. but its easy to solve.

jsut add a new parameter.

and replace it with HKEY_CURRENT_USER.

here is my code:

useage:
invoke SetRegString, HKEY_LOCAL_MACHINE,

chr$("Software\MASM\Registry Test\"),
chr$("StringKeyName"),
chr$("aaa")



SetRegString  proc reg_HKEY:dword, lpszKeyName:dword, lpszValueName:dword, lpszString:dword

local Disp: dword
local pKey: dword
local dwSize: dword
invoke RegCreateKeyEx, reg_HKEY,
lpszKeyName, NULL, NULL,
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL,
addr pKey, addr Disp
.if eax == ERROR_SUCCESS
invoke lstrlen, lpszString
mov dwSize, eax
invoke RegSetValueEx, pKey, lpszValueName,
NULL, REG_SZ,
lpszString, dwSize
push eax
invoke RegCloseKey, pKey
pop eax
.endif
ret
SetRegString endp
Posted on 2004-11-16 15:22:28 by diablo2oo2
awesome! I was on the right track.

Could it be I am getting the hang on this... slowly? :o
Posted on 2004-11-16 15:33:15 by TropE
its easy. add new paramater to your proc "h_regkey:dword"

and replace "HKEY_CURRENT_USER" with "h_regkey". thats all
Posted on 2004-11-16 15:51:01 by diablo2oo2