>>The ReleaseMutex has a corresponding ResetEvent. It appears you would have to shut VFP down either way because the process would have to terminate in order for it to go away on its own.
>>
>>Just some thoughts from a WinAPI layman.
>>
>Nice catch, Larry. In fact, I just finished testing this and, unfortunately, like creating a mutex, you have to clear the Event, apparently using ResetEvent() followed by a close. Serves me right for opening my mouth before reading the SDK.< g >
NO, NO, NO...I don't leverage anything from the event.
Issuing a CloseHandle() with no other process holding an event handle makes the event object disappear, regardless of the state. If you forget to CloseHandle, issuing a CLOSE ALL, or QUITting VFP releases the handle and makes the event go away. I'm actually leveraging the CreateEvent() behavior rather than the Event itself; the existance of the Event serves as an indication that someone else already is running, and is still running.
Try it. There's no causal link between PROGRAM(0) - it's just a name that's easily codified; presumably any instance of the program you're running will have the same PROGRAM(0), so even if you cancel out, a CLOSE ALL or calling CloseHandle() avoids the need to exit VFP.
RTFMSDN