🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.misc
Article #315

COM newbie question (events)...

#315
From: karipid
Date: Mon, 25 Oct 1999 00:00
72 lines
3077 bytes
Hello everyone,

I've imported a type library, from a DLL that was written in some
language, probably other than Delphi.  It contains 2 interfaces.  One
that allows me to send messages and one that is supposed to confirm
them by calling me back.  A striped down version of the type library
is given at the end of my posting.

Now, I call CoTest.create to obtain an interface to the object.  Then
I call sendMessage using the interface, which seems to go fine.  But
I'm stuck trying to figure out where to put my code for the
_ITestEvents interface...  How do I provide an implementation for the
ConfirmMessage method?  And even more puzzling to me is how on earth
will the DLL know where it is so that it can call it!

unit TESTLib_TLB;

interface
uses Windows, ActiveX, Classes, Graphics, OleCtrls, StdVCL;

const
  LIBID_TESTLib: TGUID = '{B6F79121-3ABF-11D3-9A3A-0040C72DEFFE}';
  IID_ITest: TGUID = '{B6F7912F-3ABF-11D3-9A3A-0040C72DEFFE}';
  DIID__ITestEvents: TGUID = '{B6F79131-3ABF-11D3-9A3A-0040C72DEFFE}';
  CLASS_Test: TGUID = '{B6F79130-3ABF-11D3-9A3A-0040C72DEFFE}';

type
  ITest = interface;
  ITestDisp = dispinterface;
  _ITestEvents = dispinterface;
  Test = ITest;
  ITest = interface(IDispatch)
    ['{B6F7912F-3ABF-11D3-9A3A-0040C72DEFFE}']
    procedure SendMessage(const bsMessage: WideString; out pdwMsgId:
Integer); safecall;
  end;

  ITestDisp = dispinterface
    ['{B6F7912F-3ABF-11D3-9A3A-0040C72DEFFE}']
    procedure SendMessage(const bsMessage: WideString; out pdwMsgId:
Integer); dispid 1;
  end;

  _ITestEvents = dispinterface
    ['{B6F79131-3ABF-11D3-9A3A-0040C72DEFFE}']
    procedure ConfirmMessage(const pdwMsgId: Integer); dispid 1;
  end;

  CoTest = class
    class function Create: ITest;
    class function CreateRemote(const MachineName: string): ITest;
  end;

implementation

uses ComObj;

class function CoTest.Create: ITest;
begin
  Result := CreateComObject(CLASS_Test) as ITest;
end;

class function CoTest.CreateRemote(const MachineName: string): ITest;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_Test) as ITest;
end;

end.


Sent via Deja.com http://www.deja.com/
Before you buy.
Technical Details
Message-ID: <7v24di$edg$1@nnrp1.deja.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10baee,6e71815fcb1be3e8,start
X-Google-Attributes: gid10baee,public
X-Google-Thread: 1043cf,6e71815fcb1be3e8,start
X-Google-Attributes: gid1043cf,public
X-Google-Thread: fd196,6e71815fcb1be3e8,start
X-Google-Attributes: gidfd196,public
From: karipid@my-deja.com
Subject: COM newbie question (events)...
Date: 1999/10/25
Message-ID: <7v24di$edg$1@nnrp1.deja.com>
X-Deja-AN: 540380127
X-Http-Proxy: 1.0 SIGMA_BRANCHES, 1.0 PROKROUSTIS, 1.0 x26.deja.com:80 (Squid/1.1.22) for client 194.219.13.3
Organization: Deja.com - Before you buy.
X-Article-Creation-Date: Mon Oct 25 17:35:46 1999 GMT
X-MyDeja-Info: XMYDJUIDkaripid
Newsgroups: comp.lang.pascal.delphi.misc,borland.public.delphi.oleautomation,borland.public.delphi.objectpascal
X-Http-User-Agent: Mozilla/4.61 [en] (WinNT; I)