网站首页  词典首页

请输入您要查询的函数:

 

术语 createevent
释义 CreateEvent
语法:
C++
HANDLE WINAPI CreateEvent(
__in_opt LPSECURITY_ATTRIBUTES lpEventAttributes,
__in BOOL bManualReset,
__in BOOL bInitialState,
__in_opt LPCTSTR lpName
);
CreateEvent函数
创建或打开一个有名或无名的事件对象。
要指定一个对象的访问掩码,使用CreateEventEx功能。
参数
lpEventAttributes [中,可选]
一个SECURITY_ATTRIBUTES结构的指针。如果该参数为NULL,处理不能由子进程继承。
结构的lpSecurityDescriptor成员指定一个新的事件的安全描述符。如果lpEventAttributes为NULL,事件得到默认的安全描述。对来自事件的ACL的默认安全描述或模拟的主要创造者的象征。
bManualReset [in]
如果此参数为TRUE时,函数创建一个手动重置事件对象,这需要在ResetEvent函数来设置事件状态无信号。如果此参数为FALSE,函数创建一个自动重置事件对象,系统会自动将事件状态无信号后,一个等待的线程已被释放。
bInitialState [in]
如果此参数为TRUE,该事件对象的初始状态信号,否则,它是无信号。
lpName [中,可选]
事件的对象的名称。该名称被限制为MAX_PATH字符。名称比较是区分大小写的。
如果lpName匹配现有的命名事件对象的名称,这个函数请EVENT_ALL_ACCESS访问权限。在这种情况下,bManualReset和bInitialState参数将被忽略,因为他们已经被创建进程设置。如果lpEventAttributes参数不是NULL,它确定是否可以被继承处理,但它的安全描述符的成员被忽略。
如果lpName为NULL,则事件对象创建没有名称。
如果lpName匹配相同的名称空间的另一种对象的名称(如现有的信号量,互斥体,可等待定时器,工作,或文件映射对象),函数失败,而且GetLastError函数返回出现ERROR_INVALID_HANDLE。这是因为这些对象共享相同的名称空间。
这个名称可以有一个“全球\\”或“Local \\”前缀明确创建对象的全球或会话名称空间。名称的其余部分可以包含以外的任何字符反斜杠字符(\\)。如需信息见命名内核对象。快速用户切换是使用终端服务会话。内核对象名称必须遵循概述了终端服务,使应用程序能够支持多个用户的指导方针。
Windows 2000的:如果终端服务没有运行,“全球\\”和“地方\\”前缀将被忽略。名称的其余部分可以包含反斜杠以外的任何字符的字符。
该对象可以创建一个私人空间。有关更多信息,请参见对象命名。
返回值
如果函数成功,返回值是一个句柄事件对象。如果命名事件对象函数调用之前存在,函数返回的句柄现有的对象和GetLastError返回ERROR_ALREADY_EXISTS。
如果函数失败,返回值为NULL。为了获得更多错误信息,调用GetLastError。
备注
在处理CreateEvent产生具有EVENT_ALL_ACCESS访问权限,它可以在任何函数,需要一个处理一个事件对象,提供来电者已被授予使用。如果一个事件是从服务或线程模拟不同的用户创建的,您可以申请一个安全描述符的事件当您创建,或者通过改变其默认的DACL为创建进程的默认安全描述符。有关更多信息,请参阅同步对象的安全和访问权限。
任何调用进程的线程可以指定事件对象在调用句柄在等待职能之一。单对象等待函数返回时,指定对象的状态信号。在多对象等待函数可以奉命返回或者当任何一个或指定对象的所有信号。当一个等待函数返回时,等待线程被释放继续执行。
该事件对象的初始状态,是指定的bInitialState参数。使用SetEvent函数来设置一个事件对象的状态信号。使用ResetEvent函数重置事件对象状态无信号。
当一个手动重置事件对象的状态信号,但仍暗示,直到它明确地重置为无信号的ResetEvent函数。没有等待线程或线程的数目随后开始等待指定的事件对象的操作,可以释放,而该对象的状态信号。
当自动状态重置事件对象发出信号,但仍暗示,直到一个等待线程被释放,该系统会自动复位状态无信号。如果没有线程在等待,事件对象的状态保持信号。
多个进程可以有相同的事件对象的处理,使使用的进程间同步对象。下列对象共享机制可用:
子进程的CreateProcess函数创建可以继承的句柄事件对象如果CreateEvent lpEventAttributes参数启用继承。
一个进程可以指定事件对象在调用句柄DuplicateHandle函数来创建一个重复的句柄可以被另一个进程使用。
一个进程可以指定在调用一个事件对象的名称的OpenEvent或CreateEvent功能。
使用CloseHandle函数关闭处理。该系统关闭时自动处理过程终止。事件对象被销毁时,其最后处理已关闭。
实例
举一个例子,它使用CreateEvent,请使用事件对象。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesCreateEventW(Unicode)和CreateEventA(ANSI)的
参见
CloseHandle
CreateEventEx
CreateProcess的
DuplicateHandle
事件对象
对象名称
OpenEvent
ResetEvent
SECURITY_ATTRIBUTES
SetEvent
同步功能
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==CreateEvent Function
Creates or opens a named or unnamed event object.
To specify an access mask for the object, use the CreateEventEx function.
Syntax
C++
HANDLE WINAPI CreateEvent(
__in_opt LPSECURITY_ATTRIBUTES lpEventAttributes,
__in BOOL bManualReset,
__in BOOL bInitialState,
__in_opt LPCTSTR lpName
);
Parameters
lpEventAttributes [in, optional]
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.
bManualReset [in]
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.
bInitialState [in]
If this parameter is TRUE, the initial state of the event object is signaled; otherwise, it is nonsignaled.
lpName [in, optional]
The name of the event object. The name is limited to MAX_PATH characters. Name comparison is case sensitive.
If lpName matches the name of an existing named event object, this function requests the EVENT_ALL_ACCESS access right. In this case, the bManualReset and bInitialState parameters are ignored because they have already been set by the creating process. If the lpEventAttributes parameter is not NULL, it determines whether the handle can be inherited, but its security-descriptor member is ignored.
If lpName is NULL, the event object is created without a name.
If lpName matches the name of another kind of object in the same name space (such as an existing semaphore, mutex, waitable timer, job, or file-mapping object), the function fails and the GetLastError function returns ERROR_INVALID_HANDLE. This occurs because these objects share the same name space.
The name can have a "Global\\" or "Local\\" prefix to explicitly create the object in the global or session name space. The remainder of the name can contain any character except the backslash character (\\). For more information, see Kernel Object Namespaces . Fast user switching is implemented using Terminal Services sessions. Kernel object names must follow the guidelines outlined for Terminal Services so that applications can support multiple users.
Windows 2000: If Terminal Services is not running, the "Global\\" and "Local\\" prefixes are ignored. The remainder of the name can contain any character except the backslash character.
The object can be created in a private namespace. For more information, see Object Namespaces .
Return Value
If the function succeeds, the return value is a handle to the event object. If the named event object existed before the function call, the function returns a handle to the existing object and GetLastError returns ERROR_ALREADY_EXISTS.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Remarks
The handle returned by CreateEvent has the EVENT_ALL_ACCESS access right; it can be used in any function that requires a handle to an event object, provided that the caller has been granted access. If an event is created from a service or a thread that is impersonating a different user, you can either apply a security descriptor to the event when you create it, or change the default security descriptor for the creating process by changing its default DACL. For more information, see Synchronization Object Security and Access Rights .
Any thread of the calling process can specify the event-object handle in a call to one of the wait functions . The single-object wait functions return when the state of the specified object is signaled. The multiple-object wait functions can be instructed to return either when any one or when all of the specified objects are signaled. When a wait function returns, the waiting thread is released to continue its execution.
The initial state of the event object is specified by the bInitialState parameter. Use the SetEvent function to set the state of an event object to signaled. Use the ResetEvent function to reset the state of an event object to nonsignaled.
When the state of a manual-reset event object is signaled, it remains signaled until it is explicitly reset to nonsignaled by the ResetEvent function. Any number of waiting threads, or threads that subsequently begin wait operations for the specified event object, can be released while the object's state is signaled.
When the state of an auto-reset event object is signaled, it remains signaled until a single waiting thread is released; the system then automatically resets the state to nonsignaled. If no threads are waiting, the event object's state remains signaled.
Multiple processes can have handles of the same event object, enabling use of the object for interprocess synchronization. The following object-sharing mechanisms are available:
A child process created by the CreateProcess function can inherit a handle to an event object if the lpEventAttributes parameter of CreateEvent enabled inheritance.
A process can specify the event-object handle in a call to the DuplicateHandle function to create a duplicate handle that can be used by another process.
A process can specify the name of an event object in a call to the OpenEvent or CreateEvent function.
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.
Examples
For an example that uses CreateEvent, see Using Event Objects .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesCreateEventW (Unicode) and CreateEventA (ANSI)
See Also
CloseHandle
CreateEventEx
CreateProcess
DuplicateHandle
Event Objects
Object Names
OpenEvent
ResetEvent
SECURITY_ATTRIBUTES
SetEvent
Synchronization Functions
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms682396(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:18:38