Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Out-of-process Classic COM EXE using Windows Runtime Template Library (WRL)

Tags:

com

wrl

I have followed the example here: http://msdn.microsoft.com/en-us/library/vstudio/jj822931.aspx to create an In-proc Classic COM DLL using Windows Runtime Template Library (WRL). I am also able to modify to code to run the DLL as COM surrogate (wrapped inside DllHost.exe).

However, I couldn't find the way to create an out-of-process COM EXE using the WRL. There is a simple example using barebone COM API here: http://www.codeproject.com/Articles/3173/A-simple-yet-debuggable-COM-skeleton-code, but I'd like to know how I can utilize WRL to simplify that.

Thanks.

like image 786
nikoniko Avatar asked Oct 08 '13 06:10

nikoniko


1 Answers

Yes it is possible. I just got one working. Here's the basics that are required, as compared to implementing an in-proc coclass.

  • Implement your coclass using WRL::RuntimeClass the same way you would for an in-proc class. (https://msdn.microsoft.com/en-us/library/jj822931.aspx)
  • In your main function, create a module object using WRL::Module<OutOfProc>::Create(), and call module.RegisterObjects() on startup, and module.UnregisterObjects() and module.Terminate() on shutdown.
  • You need to build a DLL to host the proxies: https://msdn.microsoft.com/en-us/library/windows/desktop/ms688707(v=vs.85).aspx
  • Static Registrations: DO register the Interface and the CLSID of your proxy stub. DO NOT statically register your coclass.
  • In the Client, when you call CoCreateInstance, be sure to use the appropriate CLSCTX. (I use CLSCTX_ALL when the hosting model is not important to the client.)

(I know it's been almost 4 years, but I had the same question this week.)

like image 126
Daniel Strommen Avatar answered Nov 15 '22 11:11

Daniel Strommen