CallProc32W

Use the CallProc32W function in 16-bit code to call an entry-point function in a 32-bit DLL.

You cannot create a prototype for CallProc32W unless you do one of the following:

This is a limitation of the Pascal calling convention. For this reason, you should use the CallProcEx32W function, which uses the C calling convention to support a variable number of arguments.

DWORD FAR PASCAL CallProc32W(
  DWORD param1,            // parameter for DLL function
  DWORD param2,            // parameter for DLL function
  ... ,                    // up to 32 parameters for DLL function
  LPVOID lpProcAddress32,  // the DLL function to be called
  DWORD fAddressConvert,   // bit mask
  DWORD nParams            // number of parameters passed
);
 

Parameters

param1 through param32
Parameters for the 32-bit procedure represented by lpProcAddress32.
lpProcAddress32
A value corresponding to the procedure to be called, which is returned by the GetProcAddress32W function.
fAddressConvert
Bit mask representing which parameters will be treated as 16:16 pointers and translated into flat linear pointers before being passed to the 32-bit procedure. The lowest bit in the mask represents the last parameter specified (paramN), the second lowest bit represents the second to the last parameter specified (paramN-1), and so on, so that the highest bit in the mask represents param1.
nParams
Number of DWORD parameters to be passed to the DLL function (param1 through paramN). For functions that take no parameters, this parameter will be zero. You can also specify the calling convention by using the OR operator to combine this value with one of the following constants:
Value Meaning
CPEX_DEST_STDCALL The function uses the standard-call calling convention. This is the default.
CPEX_DEST_CDECL The function uses the C calling convention.

Return Values

Returns the return value from the 32-bit entry-point function represented by lpProcAddress32. The return value can also be zero under the following conditions:

Remarks

CallProc32W takes at least three parameters: lpProcAddress32, fAddressConvert, and nParams. In addition, it can take a maximum of 32 optional parameters. These parameters must be DWORD types and must match the type that the 32-bit thunk DLL is expecting. If the appropriate bit is set in the fAddressConvert mask, the parameter will be translated from a 16:16 pointer to a 32-bit flat linear pointer.

CallProc32W and CallProcEx32W do not automatically fix global memory handles that are translated to 0:32 pointers. Therefore, you must call the GlobalFix or GlobalWire function on the handle first and GlobalUnfix and GlobalUnwire afterward.

Windows 95 and Windows 98: Global compaction can move memory blocks at any time while the current thread is executing 32-bit code. Because of this, not fixing segments before calling the target function works in Windows NT, but may cause race conditions in Windows 95 or Windows 98.

Note  You should be careful when using this function, because there is no compiler check made on the number and type of parameters, no conversion of types (all parameters are passed as type DWORD and are passed directly to the function without conversion). No checks of the 16:16 address are made (limit checks, NULL checks, correct ring level, and so on).

See Also

CallProcEx32W, GetProcAddress32W