In Win32 to pass a handle to an event (or anything really) you need to call the DuplicateHandle() Win32 API function call. A handle is just a DWORD value valid in that process space, so you will also need the Process Handle of the process that created the event when you call DuplcateHandle().
A easier way to do what you are trying to do is to create a _named_ event such as:
win32event.CreateEvent(None, 0, 0, 'MyProcessEvent')
Then pass the name of the event VIA COM or some other IPC mechanism or have it be a known string. The name of the event must be system wide unique or else the CreateEvent() call will fail. The receiver (client app) can call the Win32 OpenEvent() with the name of the event to get a handle to the event and then wait on that:
hDSP = win32event.OpenEvent(EVENT_ALL_ACCESS, 1, 'MyProcessEvent')
if hDSP > 32:
win32event.WaitForSingleObject(hErrorDSP, win32event.INFINITE)
else:
# call GetLastError for error code, and do something about it here
hth,
todd
> I create a COM-interface with this methods:
>
> COM-Server:
>
> def __init__(self):
> self.hError = win32event.CreateEvent(None,0,0,None)
>
> def SetErrorHandle(self):
> return self.hError
>
> When I start a WaitForSingleObject-Command on the other side, python
> tells me, that is not a PyHANDLE. How I can get a reference from the
> event over the COM-Interface?
>
> COM-Client:
>
> hErrorDSP=dsp.SetErrorHandle
> win32event.WaitForSingleObject(hErrorDSP, win32event.INFINITE)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"One word sums up probably the responsibility of any
vice president and that one word is 'to be prepared.'"
-- Vice President Al Gore, 12/6/93
Todd Palmer
Senior Software Engineer
[EMAIL PROTECTED]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython
