0

I am trying to load a C++ DLL inside my Ruby application as a binary object. I have registered the Interface using regsrv32 and load the Dll using Win32OLE .. but if i am running a 64 bit variant of Ruby I cannot load a 32 bit C++ dll and visa versa. the only combinations that works are

32 bit ruby loads a 32 bit C++ Dll. 64 bit ruby loads a 64 bit C++ Dll

The only possible way I see here is to fork out a 32 bit ruby process to register and load the 32 bit dll via Win32OLE.

Nathan
  • 674
  • 8
  • 22
  • you need register both - 32 and 64bit dlls – RbMm Jan 04 '18 at 23:07
  • Are you implying, that `x86_64` were some sort of Schroedinger-bitness? Or are you just assuming, that it means what you think? Which may well be not what it really means. – IInspectable Jan 04 '18 at 23:07
  • These articles may be helpful. [Utilizing a 32-bit DLL in a 64-bit process via COM](https://stackoverflow.com/questions/8660357/utilizing-a-32-bit-dll-in-a-64-bit-process-via-com), [64-bit client call to 32-bit COM/ATL server EXE fails](https://social.msdn.microsoft.com/Forums/vstudio/en-US/f2c10d58-ec35-4e7c-99dd-3d6c71c30112/64bit-client-call-to-32bit-comatl-server-exe-fails?forum=vcgeneral) – kunif Jan 04 '18 at 23:17
  • ignore the x86_64 comment that was purely my thought process. The articles are useful but here i am trying to access the binary object from another language - Ruby. So CoCreateInstance() wont help. – Nathan Jan 05 '18 at 03:28
  • If you want us to ignore that comment, remove it from your question. As for `CoCreateInstance`: That's how COM objects are usually instantiated. Whether you do this from C, Delphi, Go, or Ruby doesn't make a difference. You cannot use COM while side-stepping COM. Those are the rules. You're going to have to get to terms with them. – IInspectable Jan 05 '18 at 12:42

1 Answers1

0

Old question, but no answer so far, so I try :).

As ruby is using 64bit and your COM+ might be 32 bit it will not run in library mode.

To solve this you register your COM+ component and afterwards you setup your dll to a server application in dcomcnfg.exe.

enter image description here

This will run your dll in a 32 bit dllhost.exe and then ruby can successful call your DLL via dll = WIN32OLE.new("your.dll")

Note: You might need to set an extra Identiy.

YvesR
  • 5,922
  • 6
  • 43
  • 70