-
OpenEvent
鎖定
- 外文名
- OpenEvent
- 所屬學科
- 計算機
OpenEvent函數功能
打開一個已經存在的命名事件對象
OpenEvent函數原型
HANDLEOpenEvent( DWORD dwDesiredAccess, BOOL bInheritHandle, LPCTSTR lpName );
OpenEvent參數説明
該參數必須設置為以下值:
EVENT_ALL_ACCESS 指定事件對象所有可能的權限
bInheritHandle 【in】指定是否返回的句柄是否繼承 。該參數必須設置為false
lpName 【in】指向一個以null結束的字符串,即將要打開的事件對象的名字。名稱是區分大小寫的。
OpenEvent返回值
函數執行成功則返回事件對象的句柄;失敗則返回NULL,獲取錯誤信息可以使用GetLastError.
OpenEventVB聲明
Declare Function OpenEvent Lib "kernel32" Alias "OpenEventA" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal lpName As String) As Long
OpenEvent參數表
參數表 | ||
參數 | 類型及説明 | |
dwDesiredAccess | Long,下述常數之一: | |
EVENT_ALL_ACCESS | 要求對事件對象進行完全訪問 | |
EVENT_MODIFY_STATE | 允許SetEvent 和 ResetEvent函數 | |
SYNCHRONIZE | 允許事件對象的使用同步 | |
bInheritHandle | Long,如希望子進程能夠繼承句柄,則為TRUE | |
lpName | String,指定要打開的對象的名字 | |
註解 | ||
一旦不再需要,注意一定要用CloseHandle關閉事件句柄。如對象的所有句柄都已關閉,那麼對象也會刪除 |
OpenEventRemarks
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.
- 詞條統計
-
- 瀏覽次數:次
- 編輯次數:10次歷史版本
- 最近更新: JD萤火虫003