You load the Win32-based DLL, DLL32
, from APP16
by using the LoadLibraryEx32W function.
// Load the Win32-based DLL from the 16-bit code
if( NULL == (ghLib = LoadLibraryEx32W( "dll32.dll", NULL, 0 )) )
{
MessageBox( NULL, "Cannot load DLL32", "App16", MB_OK );
return 0;
}
If you are isolating your thunking code into DLL16
, you can put the call to LoadLibraryEx32W in the LibMain function of the DLL16
code.
The instance handle is stored in the following global variable:
DWORD ghLib;
When linking the 16-bit code, you need to indicate that the generic thunking functions will be imported from the system kernel. For example, using Microsoft Visual C++, you would create an IMPORTS section in the module definition (.DEF) file for APP16
, as follows.
IMPORTS
kernel.LoadLibraryEx32W
kernel.FreeLibrary32W
kernel.GetProcAddress32W
kernel.GetVDMPointer32W
kernel.CallProc32W
kernel.CallProcEx32W