Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Thunking 16Bits dll's to 32Bits Project

Posted on 1998-05-21
7
Medium Priority
?
328 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Accepted Solution

by:
abesoft earned 600 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.
Suggested Courses

971 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