Click to See Complete Forum and Search --> : OpenEvent fail when CreateEvent called from Service


PABLOCABALLERO
August 4th, 2005, 08:44 PM
I apologize by my bad english.

I am creating and event handle from a program running as a service.
I am doing this calling CreateEvent with the following parameters:

CreateEvent(NULL,FALSE,FALSE,"EVENT_NAME")

When I call OpenEvent(EVENT_ALL_ACCESS,TRUE,"EVENT_NAME") from a COM component (after that the service is started and the call of CreateEvent) the return value of this call is NULL and GetLastError return 2.

Thanks for your help

olivthill
August 5th, 2005, 03:47 AM
PABLOCABALLERO, you say that GetLastError() returns 2. This is ERROR_FILE_NOT_FOUND, and usually it is caused by a lack of privileges.

There is a question similar to yours at http://www.codeproject.com/threads/sharedmemipc.asp?select=443971&df=100, at the end of an article on Interprocess Communication. I let you read the answer.

I think you should call CreateEvent() with a first parameter indicating the security permissions you will grant.