/// <summary> /// Constructor /// </summary> /// <param name="lpEventAttributes"> /// A pointer to a SECURITY_ATTRIBUTES structure. If this parameter is NULL, the handle cannot be inherited by child processes. /// The lpSecurityDescriptor member of the structure specifies a security descriptor for the new event. If lpEventAttributes is NULL, the event gets a default security descriptor. The ACLs in the default security descriptor for an event come from the primary or impersonation token of the creator. /// </param> /// <param name="bManualReset"> /// If this parameter is TRUE, the function creates a manual-reset event object, which requires the use of the ResetEvent function to set the event state to nonsignaled. If this parameter is FALSE, the function creates an auto-reset event object, and system automatically resets the event state to nonsignaled after a single waiting thread has been released. /// </param> /// <param name="bInitialState"> /// If this parameter is TRUE, the initial state of the event object is signaled; otherwise, it is nonsignaled. /// </param> /// <param name="lpName"> /// The name of the event object. The name is limited to MAX_PATH characters. Name comparison is case sensitive. /// </param> public Event(SecurityAttributes lpEventAttributes, bool bManualReset, bool bInitialState, string lpName) { m_Handle = NTKernel.CreateEvent(lpEventAttributes, bManualReset, bInitialState, lpName); if (m_Handle == IntPtr.Zero) { int err = NTKernel.GetLastError(); throw new Exception(String.Format("Create Event fail, error={0}", err)); } }
internal static extern IntPtr CreateFileMapping(int hFile, SecurityAttributes lpAttributes, int flProtect, int dwMaximumSizeHigh, int dwMaximumSizeLow, string lpName);
internal static extern IntPtr CreateEvent(SecurityAttributes lpEventAttributes, bool bManualReset, bool bInitialState, string lpName);
internal static extern IntPtr CreateMutex(SecurityAttributes lpEventAttributes, bool bInitialOwner, string lpName);
internal static extern int CreateSemaphore(SecurityAttributes auth, int initialCount, int maximumCount, string name);