CreateMutex Function

Action

Uses the Win32 CreateMutexEx function to create a named mutex object. Mutex objects are used to serialize access to critical sections inside transactions for multiple concurrent users.

Include file

Kernel.bdh

Syntax

CreateMutex( in sMtxName: string ): number;

Return value

handle to the mutex object

Parameter Description
sMtxName Name of the mutex object

Example

dcltrans
  transaction TCloseHandle
  var
    hMutex: number;
  begin
    hMutex := CreateMutex("MutexObject");
    write("mutex object created"); writeln;
    WaitForSingleObject(hMutex, INFINITE);
    ReleaseMutex(hMutex);
    write("mutex object released"); writeln;
    CloseHandle(hMutex);
    write("handle to mutex object closed"); writeln;
  end TCloseHandle;

Output

mutex object created
mutex object released
handle to mutex object closed

Sample scripts

MutexLogin.bdf