我对 C++ 相当陌生...我的 CreateEvent 可以正常使用此代码:
HANDLE result = CreateEvent(NULL, // No security.
TRUE, // Manual-reset event.
FALSE, // Not signaled.
L"Global\\MyResetEvent"); // Event name.
但是我与安全属性有什么关系才能在 C# 中具有以下等效项?
SecurityIdentifier localSystemUsers = new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null);
SecurityIdentifier adminUsers = new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null);
EventWaitHandleAccessRule localSystemRule = new EventWaitHandleAccessRule(localSystemUsers, EventWaitHandleRights.FullControl, AccessControlType.Allow);
EventWaitHandleAccessRule adminRule = new EventWaitHandleAccessRule(adminUsers, EventWaitHandleRights.Synchronize | EventWaitHandleRights.Modify, AccessControlType.Allow);
EventWaitHandleSecurity security = new EventWaitHandleSecurity();
security.AddAccessRule(localSystemRule);
security.AddAccessRule(adminRule);
bool createdNew;
event = new EventWaitHandle(false, EventResetMode.ManualReset, MyEventName, out createdNew, security);