How can I use a legacy x86 library with my x64 Application C++?

  32bit-64bit, c++, dcom, dll

I have an internal x86 library that I need the functionality from in an application that is being ported to 64 bit, I do not have access to the source code for the library so recompiling it as 64 bit is out of the questions, and for whatever reason this application has to be ported to 64 bit so compiling it as 32 bit is also out of the question.

After days of googling the solutions I have come across tell me to create a com server and use IPC to get the results I need, which is fine however I do not know how to do this.

I should note the DLL isn’t required at compile time, it’s loaded in later, and I feel like I’ve registered the DLL with the system properly but the directions I’ve found for doing this are confusing to say the least.

                    HINSTANCE h = ::LoadLibrary(bdcComDLL);
                    FARPROC pFunc = ::GetProcAddress((HMODULE) h, "DllRegisterServer");
                    HRESULT hResult = (*pFunc)();

Is how we load this library in previously, and this works on 32 bit, but throws a Access Violation on 64 bit which makes sense because we can’t directly execute 32 bit in a 64 bit process.

So I guess my question is, how can I build a solution around a x86 dll that needs to be used in a x64 application, and is there some resource that sets up a "Hello, world!" for that solution?

Source: Windows Questions C++

LEAVE A COMMENT