Link to home
Start Free TrialLog in
Avatar of jeffg2
jeffg2

asked on

Call Watcom 32 bit DLL from Delphi 16 bit

I have a 16-bit Dephi Main program and I want to call a 32-bit DLL written in Watcom C.  The provider of the DLL used special Watcom Compiler feature to generate a Thunk DLL to handle the environment crossing, but it does not appear to work with Delphi.  The DLL writer doesn't have a clue since 'it works with other C main programs'.  They or I need help in getting this to work since they say it will take to long to recode their 32-bit DLL to 16-bit code, and will be less efficient.
Avatar of NickRepin
NickRepin

If you provide more information, may be...

1. How you call thunk DLL - at run time using LoadLibrary & GetProcAddress or at link time using LIB file?
2. How many functions exported by DLL?
3. What kind of work DLL does?
4. Is there any manuals for thunk DLL?

Writting your own thunk DLL is not simple, but possible.
May be better try to use provider's thunk DLL.
Avatar of jeffg2

ASKER

1. I use the standard Delphi method of calling the DLL which
creates a link at compile time, not LoadLibrary

2. 4 functions open, close, encode, decode

3. Voice compression/decompression

4. For now I cannot release info due to Non Disclosure Agreement.

Other info:

The DLL uses calloc() to create a block of storage upon
opening, and stores 32-bits of info (the flat address?)
in a Long whose address I provide in the open call.

The THUNK was written by the developer of the 32-bit DLL
using a special tool provided by Watcom.
Please post headers for the C functions, and the 'external' declarations you use in Delphi.

If it works with 16-bit C, it also works with the Delphi. The only exception are functions taking variable number of parameters, which is a bit more tricky.

Regards,

Erik.
Please post headers for the C functions, and the 'external' declarations you use in Delphi.

If it works with 16-bit C, it also works with the Delphi. The only exception are functions taking variable number of parameters, which is a bit more tricky.

Regards,

Erik.
There are different thunking mechanisms, for the
different platforms 3.1, 95 and NT.  You need to know
which platform he created it for, and make sure that it
is the same as the one that you are using.  The different
mechanisms are mutually exclusive.
Avatar of jeffg2

ASKER

The Problem is solved.  Thanks for trying. For all of your info the problem was related to floating point traps.  Delphi enables them, most other languages apparently do not.  The DLL caused floating underflows which normally had no affect, but with a Delphi Main, caused a trap.

Case Closed.

ASKER CERTIFIED SOLUTION
Avatar of Shrif
Shrif

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial