hi

i write a program to add a value in windows registry but it didn't work
and doesn't add anything in registry, what's a problem?
my assembler is masm32.

and here is my code:

.386
.model flat, stdcall
option casemap:none

include windows.inc
include kernel32.inc
include advapi32.inc

includelib kernel32.lib
includelib advapi32.lib

.data
    szRegSubKey db    "Software\Microsoft\Windows\CurrentVersion\Policies\System", 0
    szValue     db    "DisableTaskMgr", 0
	
.data?
    hKey    PHKEY    ?

.code
start:

    invoke  RegOpenKeyEx, RegOpenKeyEx, ADDR szRegSubKey, NULL, KEY_ALL_ACCESS, ADDR hKey
	
    OR    EAX, EAX
    JNE   _error
		  invoke  RegSetValueEx, hKey, ADDR szValue, NULL, REG_DWORD, 1, DWORD

_error:

    invoke  RegCloseKey, hKey
    invoke  ExitProcess, NULL

end start

try

invoke RegOpenKeyEx HKEY_LOCAL_MACHINE, ADDR szRegSubKey, NULL, KEY_ALL_ACCESS, ADDR hKey)

thanks Tight_Coder_Ex it's work. :icon_lol:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.