Well ppl, I'm having a problem detecting a error.
here is my code

.386
.MODEL flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\shell32.inc


include \masm32\lib\user32.lib
include \masm32\lib\kernel32.lib
include \masm32\lib\advapi.lib
include \masm32\lib\shell32.lib

.const
.data

hkey1 db "HKEY_LOCAL_MACHINE",0
watchtree db "TRUE",0
notify db "REG_NOTIFY_CHANGE_LAST_SET",13,10
db "REG_NOTIFY_CHANGE_SECURITY",13,10
db "REG_NOTIFY_CHANGE_NAME",0, "$"
event db "TRUE",0
async db "TRUE",0
.data?
chkerror db ?
.code
start:
invoke RegNotifyChangeKeyValue, ADDR hkey1, ADDR watchtree, ADDR notify, ADDR event, ADDR async
mov chkerror, eax;wondering if this will work
comp edx, eax; assuming the error code will be in edx
;just try it and it didn't work which reg is it in
; if functions succeeds return value is ERROR_SUCCESS
; how could I check to see if it succeeded
The above is how I coded it
Posted on 2003-02-24 13:55:24 by Tweak
What is this?

comp edx, eax;assuming the error code will be in edx
Posted on 2003-02-24 16:28:01 by kairon
Basically was trying to use a error checking rountine to be sure that api's function
succeeded.
Was thinking the error code would be in a register that I could check and comp.
If not please let me know how to properly use error checking or where to learn more about it.
Posted on 2003-02-24 18:11:48 by Tweak
I use FormatMessage like this:

.data

errorMesssage dd 0
errorMsgbuff dd 0
loclock dd 0


cmp eax,0
jne go5
call DisplayLastError
int 3

go5:



DisplayLastError:

push eax
invoke GetLastError
mov regXXX,eax
mov MsgSrc,eax
call DisplayregXXX
invoke LocalAlloc ,LMEM_MOVEABLE or LMEM_ZEROINIT,1000
mov errorMsgbuff,eax
mov loclock,eax
invoke LocalLock,loclock
invoke FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM,0,MsgSrc,0,addr errorMsgbuff,0,NULL
invoke wsprintf, addr buffer, addr errorMessage,errorMsgbuff
invoke MessageBox,0,addr buffer, addr AppName, MB_OK+MB_ICONINFORMATION
invoke LocalUnlock,addr loclock
invoke LocalFree,addr errorMsgbuff
pop eax
ret
Posted on 2003-02-24 20:33:14 by mrgone