Introduction to Bold + DCOM

A step-by-step walk through of separating business logic to another server using BOLD + DCOM with an Interbase database.

This article was compiled from logs of an internet chat (IRC) with Eric Holton. I would like to thank Eric for spending so much time detailing the steps envolved. Eric has agreed to let me convert the logs of our conversation into this article for the benefit of others.

The server

  1. Create a new application with a form and a datamodule.

  2. Name the module dmServer, and the main form fmServerMain.

  3. Save the form as ServerMainForm.pas, the module as ServerModule.pas, and the project as ServerApp.DPR

  4. From the [Bold Handles] tab add a TBoldModel (mbModel), TBoldSystemTypeInfoHandle (ihModelInfo), TBoldSystemHandle (shMainHandle), and a TBoldPersistenceHandleIB (phInterbase).

  5. In the object inspector set the following properties:



        DatabaseName = an existing GDB file to be replaced.

        BoldModel = bmModel

        DatabaseEngine = dbeInterbaseSQLDialect3


        SystemTypeInfoHandle = ihModelInfo

        PersistenceHandle = phInterbase

        IsDefault = True

        AutoActivate = True


        BoldModel = bmModel



  6. In the OnDestroy of the datamodule include the following code


      if Assigned(shMainHandle.System) then

        with shMainHandle.System do

          if BoldDirty then Discard;


  7. Double click the model to bring up the model editor, and do the following:

    1. Change "Name" and "Unit name" from BusinessClasses to DCOMTestClasses

    2. Change "Model root class" from BusinessClassesRoot to DCOMTestClassesRoot

    3. Add a new class called Person with a single attribute "firstName"

    4. Tools menu, Generate database

    5. Tools menu, Generate code - save the resulting files with their default names

    6. Tools menu, Generate COM/IDL GUIDs (say YES to "Keep existing GUIDs?")

    7. Tools menu, Generate Delphi compatible IDL - save the results files with their default names

    8. Save the model, and then close the model editor


  8. File menu, New, [ActiveX] tab, "Type library" and do the following:

    1. Click the [Uses] tab

    2. Right-click and select "Show All Type Libraries"

    3. Tick "Bold ObjectSpace Type Library"

    4. Right-click and select "Show selected"

    5. Open the file DCOMTesterClasses.IDL

    6. Select all of the text and copy it to the clipboard

    7. Click the [Text] tab on the TLB editor

    8. Replace all of the text with the text in the clipboard

    9. Click "Refresh implementation"

    10. CTRL+S and save the TLB as the default name (ProjectName.TLB)



  9. From the [Bold COM] tab drop the following components onto the server module TBoldCOMServerHandle (cshServerHandle) and a TBoldComServerElementHandle (cseElementHandle) and set the following properties:



        BoldHandle = shMainHandle

        ServerHandle = cshServerHandle


  10. Double-click cshServerHandle and generate code, save this file as DCOMTestServerCode.pas

  11. Copy the GUID from DCOMTestServerCode to the clipboard

  12. Save and run the application, all should be well.

The Client

  1. Register the server's TLB file using RegSvr32 or TRegSvr (borland\delphi\bin folder).

  2. Create a new application with a form and a datamodule (the form should "Use" the module).

  3. Name the module dmClient, and the main form fmClientMain.

  4. Save the form as ClientMainForm.pas, the module as ClientModule.pas, and the project as ClientApp.DPR

  5. From the [Bold COM] tab add a TBoldCOMConnectionHandle (chCOMConnection), and a TBoldSystemHandleCom (shMainHandle) set the following properties



        ServerCLSID = the GUID from DCOMTestServerCode.pas (The ServerName property should alter automatically)

        AutoConnect = True


        ConnectionHandle = chCOMConnection

        IsDefault = TRUE

        ObjectName = (Same as ObjectName of cseElementHandle in the server)


  6. From the [Bold COM Handles] tab drop a TBoldListHandleCom (blhPerson) on to your main form, set


      ConnectionHandle = dmClient.chCOMConnection

      Expression = 'Person.allInstances'

      RootHandle = dmClient.shMainHandle


  7. From the [Bold COM Controls] tab drop a TBoldGridCom and a TBoldNavigatorCom on to your main form and set the BoldHandle property of both to blhPerson.

  8. Right-click BoldGridCOM1 and select "Edit columns" set the Expression property of the second column to "firstName".

  9. Add a button to your form with the following code attached




Your application should now work.


Share this article!

Follow us!

Find more helpful articles: