Modifica

Condividi tramite


MutexAcl.TryOpenExisting(String, MutexRights, Mutex) Method

Definition

Tries to open a specified named mutex, if it already exists, applies the desired access rights, and returns a value that indicates whether the operation succeeded.

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);
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

Parameters

name
String

The name of the mutex to be opened. If it's prefixed by "Global", it refers to a machine-wide mutex. If it's prefixed by "Local", or doesn't have a prefix, it refers to a session-wide mutex. Both prefix and name are case-sensitive.

rights
MutexRights

The desired access rights to apply to the returned mutex.

result
Mutex

When this method returns true, contains an object that represents the named mutex if the call succeeded, or null otherwise. This parameter is treated as uninitialized.

Returns

true if the named mutex was opened successfully; otherwise, false.

Exceptions

name is null

name is an empty string.

A Win32 error occurred.

The named mutex exists, but the user does not have the security access required to use it.

Applies to