MutexAcl.TryOpenExisting(String, MutexRights, Mutex) 方法

定义

尝试打开指定的命名互斥体(如果已存在),应用所需的访问权限,并返回一个值,该值指示作是否成功。

public:
 static bool TryOpenExisting(System::String ^ name, System::Security::AccessControl::MutexRights rights, [Runtime::InteropServices::Out] System::Threading::Mutex ^ % result);
public static bool TryOpenExisting(string name, System.Security.AccessControl.MutexRights rights, out System.Threading.Mutex? result);
public static bool TryOpenExisting(string name, System.Security.AccessControl.MutexRights rights, out System.Threading.Mutex result);
static member TryOpenExisting : string * System.Security.AccessControl.MutexRights * Mutex -> bool
Public Shared Function TryOpenExisting (name As String, rights As MutexRights, ByRef result As Mutex) As Boolean

参数

name
String

要打开的互斥体的名称。 如果前缀为“Global”,则表示计算机范围的互斥体。 如果前缀为“Local”,或没有前缀,则它引用会话范围的互斥体。 前缀和名称都区分大小写。

rights
MutexRights

要应用于返回的互斥体所需的访问权限。

result
Mutex

当此方法返回 true时,包含一个对象,该对象表示命名互斥体(如果调用成功,否则 null )。 此参数被视为未初始化。

返回

true 如果已成功打开命名的互斥体,则为 ;否则,为 false.

例外

namenull

name 是空字符串。

发生了 Win32 错误。

命名互斥体存在,但用户没有使用它所需的安全访问权限。

适用于