CVIRTEHasBeenDetached

CVIRTEHasBeenDetached (void);

Purpose

Indicates whether the operating system has detached the LabWindows/CVI Run-Time Engine from your executable process. The operating system detaches the run-time engine from a process in the following cases:

You might need to use CVIRTEHasBeenDetached if you call LabWindows/CVI library functions in response to a PROCESS_DETACH message in the DllMain function of a DLL. In some cases, the operating system sends a PROCESS_DETACH message to the LabWindows/CVI Run-time Engine before it sends a PROCESS_DETACH message to your DLL. When the LabWindows/CVI Run-time Engine receives a PROCESS_DETACH message, it releases all the system resources it has acquired. When, in response to the PROCESS_DETACH message, your DLL calls LabWindows/CVI library functions that assume the system resources are still present, a general protection fault occurs.

A similar case occurs when you call the atexit function in a DLL to register a routine for the ANSI C library to execute when your DLL unloads. The ANSI C library calls your routine when the DLL receives a PROCESS_DETACH message. This can occur after the LabWindows/CVI Run-time Engine receives a PROCESS_DETACH message. If your registered function calls LabWindows/CVI library functions that assume the system resources are still present, a general protection fault occurs.

To prevent such problems, call LabWindows/CVI functions from the PROCESS_DETACH code and registered functions in your DLL only if CVIRTEHasBeenDetached returns 0.

Example

int myPanel = 0;

int CreatePanel (void)
{

if ((myPanel = LoadPanel (0, "my.uir", MY_PANEL) < 0)

return 0;

atexit (CleanupPanels)
return 1;

}

static void CleanupPanels (void)
{

if ( ! CVIRTEHasBeenDetached())

if (panel > 0)

   DiscardPanel(myPanel);

}

Parameters

None.

Return Value

Name Type Description
hasBeenDetached integer 1 = The run-time engine has already received the PROCESS_DETACH message. Do not call LabWindows/CVI library functions.

0 = The run-time engine has not yet received a PROCESS_DETACH message. You can safely call LabWindows/CVI library functions.