Click here to Skip to main content
15,895,793 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created Event
HANDLE h = CreateEvent(NULL, FALSE, FALSE, "eventname");
And open it in another process
HANDLE h1 = OpenEvent(EVENT_MODIFY_STATE, FALSE, "eventname");

It work fine when I run normally.
But when I have created event in windows service it gives error Access denied while opening event.
Can anybody give sujjection to this problem
Posted
v2
Comments
Herman<T>.Instance 18-Jul-11 5:54am    
under which user runs the windows service?

Here is the signature for CreateEvent
HANDLE WINAPI CreateEvent(
  __in_opt  LPSECURITY_ATTRIBUTES lpEventAttributes,
  __in      BOOL bManualReset,
  __in      BOOL bInitialState,
  __in_opt  LPCTSTR lpName
);


You ave to pass a SECURITY_ATTRIBUTES structure granting access to the user (or a group) that will call OpenEvent.

Take a look at Creating a Security Descriptor for a New Object in C++[^] - it shows how to work with SECURITY_ATTRIBUTES.

Best regards
Espen Harlinn
 
Share this answer
 
I think it has something to do with first parameter LPSECURITY_ATTRIBUTES. in msdn it is suggested "If this parameter is NULL, the handle cannot be inherited by child processes.".

You better try to fix this issue.

MSDN link
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900