National Instruments 320685D-01 Drums User Manual


 
Chapter 4 Windows 3.1 Compiler/Linker Issues
LabWindows/CVI Programmer Reference Manual 4-14
©
National Instruments Corporation
static long FAR CallbackHelper(long data)
{
return (*UsersCallback)(data);
}
/* Modified glue code for the function that installs the */
/* callback. */
long InstallCallback(long (*callback)(long))
{
long retval;
unsigned short cw387;
UsersCallback = callback; /* Store CVI 32-bit pointer */
/* in static variable. */
/* Create a 16-bit thunk for the 32-bit far function */
/* CallbackHelper */
if ((CallbackData.UserDefinedProcHandle =
GetProcUserDefinedHandle()) == 0)
return FALSE;/* Too many callbacks installed */
/* or handles not freed. */
if (DefineUserProc16(CallbackData.UserDefinedProcHandle,
(PROCPTR) CallbackHelper, UDP16_DWORD,
UDP16_CDECL, UDP16_ENDLIST))
goto failed;
if (!(CallbackData.proc16 =
GetProc16((PROCPTR)CallbackHelper,
CallbackData.UserDefinedProcHandle)))
goto failed;
CallbackData.proc16Instance =
MakeProcInstance(CallbackData.proc16,
GetTaskInstance());
cw387 = Get387CW();
retval = (long)
InvokeIndirectFunction(__static_InstallCallback,
CallbackData.proc16Instance);
Set387CW(cw387);
return retval;
00ProRef.book : 06chap04.fm Page 14 Monday, March 9, 1998 3:23 PM