Minimum code needed to create the 16bit portion of the thunking layer

Note that XXXX is the base name — that is, you would replace "XXXX" with the name of the thunk script file.

// prototype for function in .obj file from the thunk script
BOOL WINAPI __export XXXX_ThunkConnect16(LPSTR lpDll16,
                                                                   LPSTR lpDll32,
                                                                   WORD hInst,
                                                                   DWORD dwReason);


// main dll entry point. the CPL32_ThunkConnect16 function must be called 
// each time the the dll is initialized
BOOL WINAPI __export DllEntryPoint(DWORD dwReason,
                                                                WORD hInst,
                                                                WORD wDS,
                                                                WORD wHeapSize,
                                                                DWORD dwReserved1,
                                                                WORD wReserved2)

        if( !(XXXX_ThunkConnect16( "Your16bitDllName.DLL", // name of 16-bit DLL 
                                                "Your32bitDllName.DLL", // name of 32-bit DLL 
                                                hInst, dwReason)) ) 
        { 
            return FALSE; 
        } 
        return TRUE; 
}

 

Minimum code needed to create the 32bit portion of the thunking layer

Note that XXXX is the base name — that is, you would replace "XXXX" with the name of the thunk script file.

// prototype for function in .obj file from the thunk script
BOOL WINAPI XXXX_ThunkConnect32(LPSTR lpDll16,
                                                    LPSTR lpDll32,
                                                    HINSTANCE hDllInst,
                                                    DWORD dwReason);


// main dll entry point
BOOL WINAPI DllMain(HINSTANCE hDLLInst,
                                            DWORD dwReason,
                                            LPVOID lpvReserved)
{
        if (!XXXX_ThunkConnect32("Your16bitDllName.DLL", // name of 16-bit DLL
                                              "Your32bitDllName.DLL", // name of 32-bit DLL
                                                 hDLLInst, dwReason))
        {
            return FALSE;
        }

        return TRUE;
}