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
Edited 17-Jul-11 23:56pm
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
0 Sergey Alexandrovich Kryukov 643
1 OriginalGriff 550
2 CPallini 415
3 George Jonsson 231
4 ChauhanAjay 150
0 OriginalGriff 5,450
1 CPallini 4,500
2 Sergey Alexandrovich Kryukov 4,032
3 George Jonsson 3,057
4 Gihan Liyanage 2,445


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100