I am trying to change our 16-bit Visual C 1.5 application to Visual C 4.1. But the application still uses some 16-bit DLLs, and I cannot get the 32-bit version. When I link the program I get the message "fatal error LNK1136: invalid or corrupt file."
I have looked for the information in the Help and the MSDN Library CD, but I cannot fix this error. I know in a Visual Basic 32-bit application I cannot use a VBX, but I don't know whether I can use a 16-bit DLL in Visual C 4.1. How can I fix this problem?
Thanks.
Tony Chen
What you need to do isn't trivial, but it looks like the patient will live.
You can't call directly from a 32-bit program to a 16-bit program (nor the other way around). However, with some restrictions, you can construct a "thunk," or a special chunk of code that translates the call for you. Check out the section on the "Thunk Compiler" in the "Programmer's Guide to Windows 95" in the Win32 SDK, available in the MSDN Library or in the Visual C++ documentation. Note that you can't call 16-bit DLLs from 32-bit applications under Windows NTonly under Windows 95.
An alternativeif you can stick with standard OLE interfaces (including IDispatch)is to write 16-bit OLE object wrappers for your DLLs. These wrappers can be called from either 16-bit or 32-bit code and from any language that can access OLE objects. Check out KnowledgeBase article Q141939 (Knowledge Base, Visual Basic for Windows KBase, Miscellaneous Related Information).
In the long term, you should figure out a way not to be dependent on the 16-bit DLL. It's like quitting smoking: tough to do, but good for your heart and lungs.