Kernel32CreateMutexEx(SecurityAttributes, String, CreateMutexFlags, UInt32) Method
Creates or opens a named or unnamed mutex object and returns a handle to the object.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", CharSet = CharSet.Auto, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)]
public static IntPtr CreateMutexEx(
[OptionalAttribute] SecurityAttributes mutexAttributes,
[OptionalAttribute] string name,
CreateMutexFlags flags,
uint desiredAccess
)
<DllImportAttribute("Kernel32.dll", CharSet := CharSet.Auto, BestFitMapping := false,
ThrowOnUnmappableChar := true, SetLastError := true>]
Public Shared Function CreateMutexEx (
<OptionalAttribute> mutexAttributes As SecurityAttributes,
<OptionalAttribute> name As String,
flags As CreateMutexFlags,
desiredAccess As UInteger
) As IntPtr
Dim mutexAttributes As SecurityAttributes
Dim name As String
Dim flags As CreateMutexFlags
Dim desiredAccess As UInteger
Dim returnValue As IntPtr
returnValue = Kernel32.CreateMutexEx(mutexAttributes,
name, flags, desiredAccess)
public:
[DllImportAttribute(L"Kernel32.dll", CharSet = CharSet::Auto, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)]
static IntPtr CreateMutexEx(
[OptionalAttribute] [InAttribute] SecurityAttributes mutexAttributes,
[OptionalAttribute] [InAttribute] String^ name,
CreateMutexFlags flags,
unsigned int desiredAccess
)
[<DllImportAttribute("Kernel32.dll", CharSet = CharSet.Auto, BestFitMapping = false,
ThrowOnUnmappableChar = true, SetLastError = true)>]
static member CreateMutexEx :
[<OptionalAttribute>] mutexAttributes : SecurityAttributes *
[<OptionalAttribute>] name : string *
flags : CreateMutexFlags *
desiredAccess : uint32 -> IntPtr
No code example is currently available or this language may not be supported.
- mutexAttributes SecurityAttributes (Optional)
-
A pointer to a SecurityAttributes structure.
If this parameter is NULL, the mutex handle cannot be inherited by child processes.
The SecurityDescriptor member specifies a security descriptor for the new mutex.
If mutexAttributes is NULL, the mutex gets a default security descriptor.
The ACLs in the default security descriptor for a mutex come from the primary or impersonation token of the creator.
- name String (Optional)
-
The name of the mutex object. The name is limited to MAX_PATH characters. Name comparison is case sensitive.
If name is NULL, the mutex object is created without a name.
If name matches the name of an existing event, semaphore, 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 namespace.
The name can have a "Global" or "Local" prefix to explicitly create the object in the global or session namespace.
The remainder of the name can contain any character except the backslash character ().
- flags CreateMutexFlags
-
Mutex creation flags.
- desiredAccess UInt32
-
The access mask for the mutex object.
IntPtr
If the function succeeds, the return value is a handle to the newly created mutex object.
If the function fails, the return value is
Zero.
If the mutex is a named mutex and the object existed before this function call,
the return value is a handle to the existing object,
GetLastError returns
ERROR_ALREADY_EXISTS.,
InitialOwner is ignored, and the calling thread is not granted ownership.
However, if the caller has limited access rights, the function will fail with
ERROR_ACCESS_DENIED and the caller should use the
OpenMutex(UInt32, Boolean, String) function.