0

Probably I miss something very basic but I haven't found the solution on stack overflow / google / etc.

I need to write a COM server in C++ Builder (XE7), 64bit if this makes any difference. As a first step, I can create an in-proc COM server, it compliles, works, and it is properly registered. But I need an out-of-proc COM server, and I am lost in the transition. (Need: external requirement to use out-of-proc COM, I cannot change it.)

What I understood from the documentation ( http://docwiki.embarcadero.com/RADStudio/Seattle/en/COM_Servers ) is that: most likely I should set the 'threading model' properly, and probably some other modification is needed ( http://docwiki.embarcadero.com/RADStudio/Seattle/en/COM_Object_Wizard), but whatever I try, I just don't get an EXE from it.

I could really appreciate a pointer to an example, or a few words where are the essential differences, or which dialog should I study more, etc.

  • 1
    File->New->Other->VCL Forms Application (which creates the .exe). Once the form displays, use File->New->Other->ActiveX->COM Object. – Ken White Mar 09 '16 at 16:39
  • And if you don't need a GUI, you can remove the default `TForm` that the `VCL Forms Application` wizard creates. – Remy Lebeau Mar 09 '16 at 23:43
  • 1
    Thanks! it is indeed a step forward but I still miss a detail: How do I register the COM server? Here it seems it is more or less equivalent with a DLL just in an EXE form. But with the above solution I get an application which by the way contains COM object. How can I expose this COM object to a COM client (through the windows registry)? I try to achive the point where I can register the out-of-process COM server into the registry this way: http://docwiki.embarcadero.com/RADStudio/Seattle/en/Registering_a_COM_Object –  Mar 11 '16 at 09:38
  • A COM in-proc server is registered using regsrv32.exe. A COM out-proc server written in Delphi/C++Builder is registered by running the .exe with the `/regserver` command line switch. Either way, the COM object gets registered in the Registry, and then clients can access it the same way (`CoCreateInstance()`) without caring if it is in-proc or out-proc. – Remy Lebeau Apr 03 '16 at 15:42
  • Actually, I realized that the answer above is correct, just I did not understand it due to my limited background in COM. What I missed but now is clear: when you start the exe, it processes the CLI parameters, registers/deregisters the COM objects and exits. Without the /regserver /unregserver it runs the main code. (My original and wrong understanding was that there are two kind of EXEs, one for regular applications and one for COM servers.) Anyway, thanks for the help. –  Apr 04 '16 at 19:33
  • @user2473983 How did you create COM Server? –  Jun 15 '16 at 05:07
  • Most simple is to use a wizard from the IDE. I guess you are interested in C++Builder (because that was the original question), but other tools (e.g. Visual Studio) have very similar features. The links in the original question are good for start. (Or you can open a new question about this topic.) –  Jun 16 '16 at 05:51

0 Answers0