Solved

Thunking 16Bits dll's to 32Bits Project

Posted on 1998-05-21
7
319 Views
Last Modified: 2012-06-27
How can I use a 16 Bits dll in my 32 Bits App using Borland C++ 5.02?
0
Comment
Question by:nosredna
  • 3
  • 2
  • 2
7 Comments
 
LVL 11

Expert Comment

by:alexo
ID: 1164448
You'll have to use the "Flat thunks" mechanism.  Use the thunk compiler (thunk.exe).
The process is explained in KB articles Q125715 and Q142564.  Also see the Borland help about "flat thunks" and "thunk compiler"



0
 

Author Comment

by:nosredna
ID: 1164449
alexo's, thanks for your answer, but
I would like a response step by step how to proceed. I've tried some times to use
Thunk.exe with a script file .thk but there was some error messages.


Thanks.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1164450
Never used it myself.  If you reopen the question somebody else may give you a better answer.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Accepted Solution

by:
abesoft earned 200 total points
ID: 1164451
Well, this is a complex problem.

There are no truly portable thunking mechanisms available under Win32.  There are "Universal thunks", "Flat thunks", and one other one that I can't remember at the moment, but none of them are available under 95, NT, and Win32s.  (I am assuming that you only care about Intel chips for NT, right?  Otherwise, I think you're completely out of luck, since Alpha etc doesn't run 16 bit apps...)  Also, under NT, there are no MS-provided thunks that will let a 32-bit process call a 16-bit DLL.

When I had to solve this problem, I used DDE in a C++ class provide thunks across all win32 platforms.  It wasn't exactly pretty, but here's the general gist:
1) The main entry point of the app was a 16-bit executable, and it would first detect that you had Win32s or a real 32 bit platform to run on.  (This was a nice side-effect of the solution...)  It would then exec the real 32-bit app, and open a connection to it.
2) Whenever a 32-bit routine wanted to call a thunked routine, it would call it via a class that I had written.
3) The class would take the function parameters, convert them into a portable format (in this case, text... watch out for pointers...) and pass them via DDE to the 16-bit executable.
4) The 16-bit executable would decode the parameters, dynamically load the DLL, and call the function.  It would then encode the result and pass it back....

Obviously, adding a new routine involved writing a fair amount of code, but it is mostly cookie-cutter stuff if you design your class nicely.

Other options avaialble are wrapping the whole thing in OLE (which was not an option for us since we wanted to support early Win32s which didn't do OLE), use WM_COPYDATA instead of DDE (not available on all platforms) or, well, there are a LOT of options here... but they all come down to the same kind of approach.
0
 
LVL 2

Expert Comment

by:abesoft
ID: 1164452
Just remembered it: The other thunk mechanism is "Generic Thunk".  (And all none of the MS-thunks are generic or universal, regardless of the neames... ;)
0
 
LVL 11

Expert Comment

by:alexo
ID: 1164453
There are "flat", "generic" and "universal" thunks.  Some are Win95 specific, some are for NT and some work with Win32s.  Check the KB articles I mentioned in my rejected answer.
0
 

Author Comment

by:nosredna
ID: 1164454
It seems very easy and I will try.
Thanks for your answer.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now