Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.10.29;
Скачать: CL | DM;

Вниз

А как использовать события в COM?   Найти похожие ветки 

 
Nick Denry ©   (2005-08-25 00:50) [0]

И интерфейсы типа IDispatch?

Откуда копать?

С уважением, Nick Denry.


 
Polevi ©   (2005-08-25 10:08) [1]

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;

type
 TT = class(TInterfacedObject, IDispatch)
 private
   FMethodName:string;
 protected
   { IDispatch }
   function GetTypeInfoCount(out Count: Integer): HResult; stdcall;
   function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;
   function GetIDsOfNames(const IID: TGUID; Names: Pointer;
     NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; stdcall;
   function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
     Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;
 end;

 TForm1 = class(TForm)
   Button1: TButton;
   procedure Button1Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

uses ActiveX, ComObj;

{$R *.dfm}

{ TT }

function TT.GetIDsOfNames(const IID: TGUID; Names: Pointer; NameCount,
 LocaleID: Integer; DispIDs: Pointer): HResult;
begin
 if NameCount <> 1 then
   Result := E_NOTIMPL else
 begin
   FMethodName:=WideString(POleStrList(Names)^[0]);
   PDispIdList(DispIDs)^[0] := 0;
   Result:=S_OK;
 end;
end;

function TT.GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult;
begin
 Result := E_NOTIMPL;
end;

function TT.GetTypeInfoCount(out Count: Integer): HResult;
begin
 Count := 0;
 Result := S_OK;
end;

function TT.Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
 Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult;
begin
 ShowMessage(FMethodName);
 Result:=S_OK;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
 x:OleVariant;
begin
 x:=TT.Create as IDispatch;
 x.Test;
end;

end.


 
Карелин Артем ©   (2005-08-29 18:18) [2]

мне нравится статья "Обратные вызовы в MIDAS через TSocketConnection" на rsdn.ru



Страницы: 1 вся ветка

Текущий архив: 2006.10.29;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.054 c
15-1160337409
ArtemESC
2006-10-08 23:56
2006.10.29
Winamp 5


3-1156953026
bmp2006
2006-08-30 19:50
2006.10.29
Не удается выполнить запрос с подзапросом


15-1160461602
ors_archangel
2006-10-10 10:26
2006.10.29
Как на асме посчитать арктангенс


2-1160992430
cooc
2006-10-16 13:53
2006.10.29
Всем привет


2-1160465616
B0Bka
2006-10-10 11:33
2006.10.29
МП3 таг