Search code examples
delphicalldcom

Call Delphi DCOM


I am totally new to Delphi and DCOM. I was assigned the task of modifying the old Delphi project. I am able to make the change and build .exe. I am using Delphi 7 IDE.

For some reason, we need the old version and the new one running on the same server at the same time.

What I did is, built the new version, let's call it delphiapp_original.exe, renamed it to delphiapp_new.exe. The way we run the application is like:

callerapp delphiapp_original.ObjA

callerapp is another application who calls Delphi DCOM objects.

My question is how to run my new Delphi application. Is it:

callerapp delphiapp_new.ObjA

I know my question sounds stupid, but I don't have environment to test so I am not able to try the command. Another reason I am asking is that I am not sure if delphiapp_original or delphiapp_new in the above command line are the name of the exe or the name of some class/object inside the exe. It would be good if they are the name of the exe, thus different DCOM objects will be called. But if delphiapp_original or delphiapp_new in the above command line are the name of the class/object inside the exe, that would cause trouble since I only renamed the exe, all the things inside the old exe and new exe remain the same name, I won't know which object is called.


Solution

  • As you suspected, it is not enough to just rename the EXE file. You have to edit the project's Type Library to change the GUID(s)/ProgID(s) of the COM object(s) that it defines. Then you can compile a new version of the EXE file and run it so its COM objects get re-registered using their new GUID(s)/ProgID(s). Then, the old and new versions will be able to co-exist on the same PC as different names.