OpenEvent

OpenEvent屬於現代數學名詞,指定對事件對象的請求訪問許可權,如果安全描述符指定的對象不允許要求通過對調用該函式的過程,函式將返回失敗。

函式功能

打開一個已經存在的命名事件對象

函式原型

HANDLEOpenEvent(
DWORD dwDesiredAccess,
BOOL bInheritHandle,
LPCTSTR lpName
);

參數說明

dwDesiredAccess 【in】指定對事件對象的請求訪問許可權,如果安全描述符指定的對象不允許要求通過對調用該函式的過程,函式將返回失敗。
該參數必須設定為以下值:
EVENT_ALL_ACCESS 指定事件對象所有可能的許可權
bInheritHandle 【in】指定是否返回的句柄是否繼承 。該參數必須設定為false
lpName 【in】指向一個已null結束的字元串,即將要打開的事件對象的名字。名稱是區分大小寫的。

返回值

函式執行成功則返回事件對象的句柄;失敗則返回NULL,獲取錯誤信息可以使用GetLastError.

VB聲明

Declare Function OpenEvent Lib "kernel32" Alias "OpenEventA" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal lpName As String) As Long

參數表
參數表
參數 類型及說明
dwDesiredAccess Long,下述常數之一:
EVENT_ALL_ACCESS 要求對事件對象進行完全訪問
EVENT_MODIFY_STATE 允許SetEventResetEvent函式
SYNCHRONIZE 允許事件對象的使用同步
bInheritHandle Long,如希望子進程能夠繼承句柄,則為TRUE
lpName String,指定要打開的對象的名字
註解
一旦不再需要,注意一定要用CloseHandle關閉事件句柄。如對象的所有句柄都已關閉,那么對象也會刪除

Remark

The OpenEvent function enables multiple processes to open handles of the same event object. The function succeeds only if some process has already created the event using the CreateEvent function. The calling process can use the returned handle in any function that requires a handle to an event object, subject to the limitations of the access specified in the dwDesiredAccess parameter.
Use the DuplicateHandle function to duplicate the handle. Use the CloseHandle function to close the handle. The system closes the handle automatically when the process terminates. The event object is destroyed when its last handle has been closed.

相關詞條

相關搜尋

熱門詞條

聯絡我們