网站首页  词典首页

请输入您要查询的函数:

 

术语 createsemaphoreex
释义 CreateSemaphoreEx
语法:
C++
HANDLE WINAPI CreateSemaphoreEx(
__in_opt LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
__in LONG lInitialCount,
__in LONG lMaximumCount,
__in_opt LPCTSTR lpName,
__reserved DWORD dwFlags,
__in DWORD dwDesiredAccess
);
CreateSemaphoreEx功能
创建或打开一个有名或无名的信号量对象,并返回的句柄对象。
参数
lpSemaphoreAttributes [中,可选]
一个SECURITY_ATTRIBUTES结构的指针。如果该参数为NULL,信号处理,不能继承的子进程。
结构的lpSecurityDescriptor成员指定一个新的信号安全描述符。如果该参数为NULL,则信号得到默认的安全描述。在对来自一个信号默认安全描述符的ACL或模拟的主要创造者的象征。
lInitialCount [in]
对于信号量对象的初始值。此值必须大于或等于零,小于或等于lMaximumCount。一个信号状态时,其信号计数大于零,无信号时,它是零。伯爵是下降了1个每当等待功能释放一个线程,这对于等待信号量。伯爵是增加了规定数额通过调用ReleaseSemaphore函数。
lMaximumCount [in]
对于信号量对象的最大数量。此值必须大于零。
lpName [中,可选]
一个指向 null 结尾的字符串指针指定的信号量对象的名称。该名称被限制为MAX_PATH字符。名称比较是区分大小写的。
如果lpName匹配现有的命名信号量对象,lInitialCount和lMaximumCount参数将被忽略,因为他们已经被创建进程中设置的名称。如果lpSemaphoreAttributes参数不为NULL,它决定是否处理可以继承。
如果lpName为NULL,则信号量对象创建没有名称。
如果lpName匹配现有的事件,互斥体,可等待定时器,工作,或文件映射对象,该函数失败,而且GetLastError函数返回出现ERROR_INVALID_HANDLE名。这是因为这些对象共享相同的名称空间。
这个名称可以有一个“全球\\”或“Local \\”前缀明确创建对象的全球或会话名称空间。名称的其余部分可以包含以外的任何字符反斜杠字符(\\)。如需信息见命名内核对象。快速用户切换是使用终端服务会话。内核对象名称必须遵循概述了终端服务,使应用程序能够支持多个用户的指导方针。
该对象可以创建一个私人空间。有关更多信息,请参见对象命名。
dwFlags
这个参数是保留,必须为0。
dwDesiredAccess [in]
为信号量对象访问掩码。如需使用权名单,见同步对象的安全和访问权限。
返回值
如果函数成功,返回值是一个句柄的信号量对象。如果命名信号量对象在函数调用之前存在,函数返回的句柄现有的对象和GetLastError返回ERROR_ALREADY_EXISTS。
如果函数失败,返回值为NULL。为了获得更多错误信息,调用GetLastError。
备注
任何线程调用进程的信号可以指定对象在调用句柄在等待职能之一。单对象等待函数返回时,指定对象的状态信号。在多对象等待函数可以奉命返回或者当任何一个或指定对象的所有信号。当一个等待函数返回时,等待线程被释放继续执行。
一个信号量对象的状态时,其信号计数大于零,无信号时,其计数等于零。在lInitialCount参数指定的初始值。每一个等待线程被释放,因为信号的信号状态,信号量的计算时间减少了1。使用ReleaseSemaphore函数增量指定数额的信号的计数。伯爵不能小于零或大于在lMaximumCount参数指定的值更大。
多个进程可以有相同的信号量对象句柄,使使用的进程间同步对象。下列对象共享机制可用:
子进程的CreateProcess函数创建可以继承的句柄量对象如果CreateSemaphoreEx lpSemaphoreAttributes参数启用继承。
一个进程可以指定信号量对象在调用句柄DuplicateHandle函数来创建一个重复的句柄可以被另一个进程使用。
一个进程可以调用指定的信号量对象的名称的OpenSemaphore或CreateSemaphoreEx功能。
使用CloseHandle函数关闭处理。该系统关闭时自动处理过程终止。信号量对象被销毁时,其最后处理已关闭。
要求:
client最低支持Vista
server最低支持 Windows Server 2008
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesCreateSemaphoreExW(Unicode)和CreateSemaphoreExA(ANSI)的
参见
CloseHandle
信号量对象
同步功能
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==CreateSemaphoreEx Function
Creates or opens a named or unnamed semaphore object and returns a handle to the object.
Syntax
C++
HANDLE WINAPI CreateSemaphoreEx(
__in_opt LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
__in LONG lInitialCount,
__in LONG lMaximumCount,
__in_opt LPCTSTR lpName,
__reserved DWORD dwFlags,
__in DWORD dwDesiredAccess
);
Parameters
lpSemaphoreAttributes [in, optional]
A pointer to a SECURITY_ATTRIBUTES structure. If this parameter is NULL, the semaphore handle cannot be inherited by child processes.
The lpSecurityDescriptor member of the structure specifies a security descriptor for the new semaphore. If this parameter is NULL, the semaphore gets a default security descriptor. The ACLs in the default security descriptor for a semaphore come from the primary or impersonation token of the creator.
lInitialCount [in]
The initial count for the semaphore object. This value must be greater than or equal to zero and less than or equal to lMaximumCount. The state of a semaphore is signaled when its count is greater than zero and nonsignaled when it is zero. The count is decreased by one whenever a wait function releases a thread that was waiting for the semaphore. The count is increased by a specified amount by calling the ReleaseSemaphore function.
lMaximumCount [in]
The maximum count for the semaphore object. This value must be greater than zero.
lpName [in, optional]
A pointer to a null-terminated string specifying the name of the semaphore object. The name is limited to MAX_PATH characters. Name comparison is case sensitive.
If lpName matches the name of an existing named semaphore object, the lInitialCount and lMaximumCount parameters are ignored because they have already been set by the creating process. If the lpSemaphoreAttributes parameter is not NULL, it determines whether the handle can be inherited.
If lpName is NULL, the semaphore object is created without a name.
If lpName matches the name of an existing event, 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.
The object can be created in a private namespace. For more information, see Object Namespaces .
dwFlags
This parameter is reserved and must be 0.
dwDesiredAccess [in]
The access mask for the semaphore object. For a list of access rights, see Synchronization Object Security and Access Rights .
Return Value
If the function succeeds, the return value is a handle to the semaphore object. If the named semaphore 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
Any thread of the calling process can specify the semaphore-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 state of a semaphore object is signaled when its count is greater than zero, and nonsignaled when its count is equal to zero. The lInitialCount parameter specifies the initial count. Each time a waiting thread is released because of the semaphore's signaled state, the count of the semaphore is decreased by one. Use the ReleaseSemaphore function to increment a semaphore's count by a specified amount. The count can never be less than zero or greater than the value specified in the lMaximumCount parameter.
Multiple processes can have handles of the same semaphore 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 a semaphore object if the lpSemaphoreAttributes parameter of CreateSemaphoreEx enabled inheritance.
A process can specify the semaphore-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 a semaphore object in a call to the OpenSemaphore or CreateSemaphoreEx function.
Use the CloseHandle function to close the handle. The system closes the handle automatically when the process terminates. The semaphore object is destroyed when its last handle has been closed.
Requirements
Minimum supported clientWindows Vista
Minimum supported serverWindows Server 2008
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesCreateSemaphoreExW (Unicode) and CreateSemaphoreExA (ANSI)
See Also
CloseHandle
Semaphore Objects
Synchronization Functions
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms682446(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:20:06