🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.pascal.delphi.misc
1 messages
1 total messages Started by karipid Mon, 25 Oct 1999 00:00
COM newbie question (events)...
#315
Author: 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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads