I need to pause process for 5 secunds. For this I try events but they works inproperly. May be you know why?

MyEvent db "MyEvent", 0
hEvent dd ?

invoke CreateEvent, 0, 0, 0, offset MyEvent
mov hEvent, eax

invoke MessageBeep, MB_OK ; SystemDefault

invoke ResetEvent, hEvent
invoke WaitForSingleObject, hEvent, 5000

invoke ExitProcess, NULL
Posted on 2003-04-22 05:22:22 by Mike
If you just need to pause for 5 seconds, do "invoke Sleep, 5000".

In your code example, you shouldn't have to ResetEvent - you're creating the even with initial state of unsignalled.

Is there any particular reason you're using a named event instead of just passing NULL for the eventname? Does the function fail?

Also, you ought to pass "NULL" as first argument, and FALSE as 2nd and 3rd. While the outcome is the same, it's a bit more "correct" programming, since the first argument is a pointer and 2nd and 3rd are booleans. Easier to see what's going on.
Posted on 2003-04-22 06:08:50 by f0dder
Not exactly. Sleep suspends the execution but I want only wait. MessageBeep needs a time to load wave file and play it. Now it cant do it because ExitProcess brakes the execution. I can write e.g.

invoke MessageBeep, ...
invoke MessageBox, ....

but in this case i need click OK or press Enter button to close message window. I want to hear beep without MessageBox and creating timers.

Posted on 2003-04-22 06:45:03 by Mike
Just exactly how does the event thingy fail?
Also, WaitForSingleObject ought to suspend execution, just like Sleep, while it's waiting for the event to be triggered (or for the timeout to occur).

Your best bet is probably to use a timer. Don't even think about coding a manual delay-loop.
Posted on 2003-04-22 06:52:23 by f0dder