16 bit DLL in 32 bit program

16 bit DLL in 32 bit program

Post by A.A.Gerritse » Sat, 26 Jul 1997 04:00:00



Hello,

Simple question with I hope a simple answere: How can I load a 16 bit DLL
with a 32 bit program.
An answere in any of the following languages would be great: MFC or Delphi

Can someone help me or give me some hints in th eright direction? Thanks in
advance.

Armin

PS Please answere also by e-mail if you don't mind.

 
 
 

16 bit DLL in 32 bit program

Post by Igor Firkusn » Fri, 01 Aug 1997 04:00:00


The only simple answer I can give you is that it is not so simple. It
can apparently be done, using the so-called "Universal Thunk", which is
a Win32 mechanism for using 16 bit code in 32 bit processes. I have
never tried it, and I suspect it is nontrivial, and probably difficult
to debug. If the DLLs are yours and you can rebuild them as 32-bit DLLs,
that's probably the best approach. If not, well, here's a basic overview
form the MSDN:

"Binary compatibility and the requirement to provide natural migration
to Windows NT and Windows 95 creates a portability problem for
developers who have Windows applications that require device drivers.
Windows NT does not support mixing 16- and 32-bit code in a Win32
process. The mixing restriction also prevents Win32-based applications
from calling 16-bit DLLs.
A number of IPC mechanisms, such as DDE, allow data to be passed between
Win32 and 16-bit Windows processes, but the bandwidth is not
sufficiently high for some types of applications. The universal thunk
(UT) allows a Win32-based application to call a routine in a 16-bit DLL.
There is also support for a 16-bit routine to call back to a 32-bit
function. The simple Win32s thunk used to implement this design also
translates a data pointer to shared memory, from flat to segmented form,
allowing large amounts of memory to be transferred between drivers and
Win32-based applications.
This design allows a Win32-based application to isolate driver-specific
routines in a 16-bit DLL. The Win32-based application remains portable
across Windows 3.1x, Windows 95, and Windows NT; in Windows NT, the
16-bit DLL is replaced with a 32-bit DLL that communicates to devices by
using the Windows NT model. A similar DLL would be written for Windows
95."

A lot more detailed stuff follows, if you have MSDN, look up "universal
thunk" and that should point you to the right set of articels; if you
don't have MSDN, you should probably get it. This stuff is also probably
discussed in some higher-level Win32 books, but I can't tell you which
ones off hand.

Good luck.

--if


> Hello,

> Simple question with I hope a simple answere: How can I load a 16 bit DLL
> with a 32 bit program.
> An answere in any of the following languages would be great: MFC or Delphi

> Can someone help me or give me some hints in th eright direction? Thanks in
> advance.

> Armin

> PS Please answere also by e-mail if you don't mind.