# CmtGetLock

int CmtGetLock (int lockHandle);

## Purpose

Gets ownership of the thread lock.

When you finish using the thread lock, you must release the lock by calling CmtReleaseLock from the same thread that called this function. Only one thread can get ownership of the thread lock at a time. If a thread requests the lock while another thread owns the lock, the calling thread waits in this function until the owning thread releases the lock. You can call this function from the same thread more than once, but you must call CmtReleaseLock once for each time that you called this function.

If you passed OPT_TL_PROCESS_EVENTS_WHILE_WAITING in the options parameter to CmtNewLock, this function processes messages while waiting for the lock.

## Parameters

Input
Name | Type | Description
lockHandle | integer | The handle you obtained from CmtNewLock to identify the thread lock.

## Return Value

Name | Type | Description
CmtStatus | integer | The CmtStatus code that the function call returns. This function returns 0 to indicate success and negative values to indicate failure. Pass the CmtStatus code to CmtGetErrorMessage to get a description of the error code.