For the EXE server, we simply create a standard EXE application: File | New Application. Delphi automatically adds a default form to our server that acts as the server's interactive user interface. If we don't want an EXE server to show this form, we simply add the following lines to our project's DPR file:
begin
Application.Initialize;
Application.ShowMainForm := False;
Application.CreateForm(...);
Application.Run;
end.
Note that it is important to have the Application.Initialize call as the first statement in the DPR file. This enables the ComObj module to initialize the COM runtime by calling CoInitialize/Ex at startup.
If you are migrating an EXE application to a COM server and forgot to call Application.Initialize, you'll get a "CoInitialize has not been called" error at the first statement that makes a COM call that requires exporting/importing a COM interface. This is a common error when migrating standalone applications into COM servers or upgrading a COM server from an older version of Delphi to Delphi 5.