Hi, I'm having some problems with WaitForMultipleObjects... I've set up two directory change notifications and they succeed, but when I try to call WaitForMultipleObjects on them, the call returns WAIT_FAILED (jumps to _ret2). What am I doing wrong? Thanks for any help

MonitorFileChanges proc

LOCAL dwWaitStatus:DWORD
LOCAL dwChangeHandles[2]:HANDLE

pusha

invoke FindFirstChangeNotification, addr DataPath, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME
mov dwChangeHandles[0], eax
cmp eax, INVALID_HANDLE_VALUE
je _ret

invoke FindFirstChangeNotification, addr DataPath, FALSE, FILE_NOTIFY_CHANGE_SIZE
mov dwChangeHandles[1], eax
cmp eax, INVALID_HANDLE_VALUE
je _ret

_loop:
;invoke WaitForSingleObject, dwChangeHandle, INFINITE
invoke WaitForMultipleObjects, 2, addr dwChangeHandles, FALSE, INFINITE
cmp eax, WAIT_FAILED
je _ret2

cmp eax, WAIT_OBJECT_0
jne @F
invoke MessageBox, NULL, addr aListChange, NULL, MB_OK

invoke FindNextChangeNotification, dwChangeHandles[0]
cmp eax, FALSE
je _ret
jmp _loop

@@:
cmp eax, WAIT_OBJECT_0 + 1
jne _ret

invoke MessageBox, NULL, addr aContentChange, NULL, MB_OK

invoke FindNextChangeNotification, dwChangeHandles[1]
cmp eax, FALSE
je _ret
jmp _loop

_ret2:
invoke MessageBox, NULL, NULL, NULL, MB_OK
_ret:
popa
ret

MonitorFileChanges endp
Posted on 2004-01-17 00:10:23 by FearHQ
FearHQ
To get extended error information, call GetLastError.
Posted on 2004-01-17 21:00:50 by P2M
You're right P2M... I'm pretty green to win32asm programming. I will do that and subsequent times.

What was wrong in my post is the way I handled arrays. I can't do

mov dwChangeHandles[1], eax

It's 4 bytes, not 1...
Posted on 2004-01-17 22:35:28 by FearHQ
It's 4 bytes, not 1...
of course
Posted on 2004-01-18 01:19:59 by P2M