Accessing 32-bit DLLs from 64-bit code

前端 未结 1 532
自闭症患者
自闭症患者 2021-01-07 08:53

I need to migrate a 32bit dll in order to use it in a 64bit C# (and also C++) applications. The dll is write in unmanaged delphi code. I can\'t recompile the dll and the onl

相关标签:
1条回答
  • 2021-01-07 09:38

    You're on the right track. You've already created and registered a COM visible wrapper DLL, which is necessary to expose the methods of your Delphi library.

    Since your x64 process can't call into this x86 wrapper, there's the need for a surrogate process. However, it makes little sense to transform your DLL to a full fledged COM+ server, if you're not going to use any of its services.

    Instead, I'd recommend hosting your wrapper DLL into the default COM surrogate. To do so, invoke the x86 based OLE/COM Object Viewer, which is part of the Windows SDK. Expand the "All Objects" node and select your COM visible class. From there, switch to the "Implementation" tab and check "Use Surrogate Process". Switch to the "Registry" tab and confirm that the "AppID" node now contains a [DllSurrogate] entry. Note: if you need to automate this step, you'll need to write the appropriate values to the registry yourself, either manually or via your setup procedure.

    You should now be able to create an instance of the COM visible wrapper class from your x64 host.

    0 讨论(0)
提交回复
热议问题