# CmtGetTSVPtr

int CmtGetTSVPtr (int variableHandle, void *variablePointer);

## Purpose

Gets the pointer to the thread safe variable.

You can use the pointer to get and/or set the value of the variable. When you finish using it, you must release the pointer by calling CmtReleaseTSVPtr from the same thread that called this function. Only one thread can access the thread safe variable at a time. If a thread requests the pointer while another has it, the second thread waits in this function until the first thread releases the pointer. You can call this function from the same thread more than once, but you must call CmtReleaseTSVPtr once for each time that you called this function.

It is difficult to program with this function directly. It is easier to program with the functions provided by the DefineThreadSafeScalarVar, DeclareThreadSafeScalarVar, DefineThreadSafeScalarVar, and DeclareThreadSafeScalarVar macros, which are defined in utility.h.

## Parameters

Input
Name | Type | Description
variableHandle | integer | The handle you obtained from CmtNewTSV to identify the thread safe variable.
Output
Name | Type | Description
variablePointer | Any pointer (passed by reference) | Returns a pointer to the thread safe variable. Pass the address of a pointer variable.

## 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.