Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++VC++
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 17-Jul-11 23:51pm
v2
Comments
digimanus at 18-Jul-11 5:54am
   
under which user runs the windows service?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 730
1 OriginalGriff 503
2 Abhinav S 278
3 thatraja 245
4 Emre Ataseven 190
0 Sergey Alexandrovich Kryukov 8,322
1 OriginalGriff 4,790
2 Peter Leow 3,784
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 18 Jul 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid