问题描述
我创建了活动
HANDLE h = CreateEvent(NULL, FALSE, FALSE, "eventname");
然后在另一个过程中打开它
HANDLE h1 = OpenEvent(EVENT_MODIFY_STATE, FALSE, "eventname");
我正常运行时效果很好.
但是当我在Windows服务中创建事件时,打开事件时会给出错误访问被拒绝.
有人可以对此问题表示怀疑吗?
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
推荐答案
HANDLE WINAPI CreateEvent(
__in_opt LPSECURITY_ATTRIBUTES lpEventAttributes,
__in BOOL bManualReset,
__in BOOL bInitialState,
__in_opt LPCTSTR lpName
);
您必须传递SECURITY_ATTRIBUTES结构,以授予将调用OpenEvent的用户(或组)访问权限.
看看为C ++中的新对象创建安全描述符 [ ^ ]-它显示了如何使用SECURITY_ATTRIBUTES.
最好的问候
Espen Harlinn
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
这篇关于openevent返回访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!