Solved

Thunking 16Bits dll's to 32Bits Project

Posted on 1998-05-21
7
322 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

808 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