Recent

Author Topic: COM Server implementation (windows)  (Read 8382 times)

BlackT

  • Newbie
  • Posts: 4
COM Server implementation (windows)
« on: October 28, 2010, 06:01:38 pm »
Hi all,

during a project run was a need to prepare a com server implementation (BTComObj.pas) for lazarus. 

It's very easy to use:
Code: [Select]
unit btcomobjectmain;

{$mode objfpc}{$H+}

interface

uses
  // runtime lib
  SysUtils, Windows,
  // dsplayer lib
  BTComObj, btcommaintestinterface;

type
  TBTComObjectMain = class(TBTComObject, IMyTestInterface)
  public
    // IMyTestInterface
    function ShowMessage(fp_Title: PWideChar;
      fp_Text: PWideChar): HResult; stdcall;
  end;

implementation

function TBTComObjectMain.ShowMessage(fp_Title: PWideChar;
  fp_Text: PWideChar): HResult; stdcall;
begin
  MessageBoxW(0, fp_Text, fp_Title,
    MB_OK or MB_DEFAULT_DESKTOP_ONLY or MB_TOPMOST or MB_ICONINFORMATION);
  Result := S_OK;
end;

initialization

TBTComObjectFactory.Create(TBTComObjectMain, CLSID_MyTestComObject,
  g_MyTestComObjectID);

end.


Download BTComObj.pas incl. example:
http://dsplayer.de/downloads/BTComObj.rar

Any feedback is welcome...


candide

  • New Member
  • *
  • Posts: 14
Re: COM Server implementation (windows)
« Reply #1 on: November 09, 2010, 04:39:51 pm »
very interesting, it is first example of COM server with Lazarus.

In this exemple, we have a COM server, a COM client and an exemple of creation of DLL : it is a very good tuto.

one remark : "unit btcomobjectmain" is not in BTComObj.rar but after creation of this file from code in this post, compilation is OK

Thanks again

BlackT

  • Newbie
  • Posts: 4
Re: COM Server implementation (windows)
« Reply #2 on: November 11, 2010, 08:40:04 am »
Thanks a lot for your feedback. I added btcomobjectmain.pas to the rar archiv.

 

TinyPortal © 2005-2018