Форум: "Основная";
Текущий архив: 2002.09.12;
Скачать: [xml.tar.bz2];
ВнизКак передать интерфейс в качестве параметра? Найти похожие ветки
← →
AFROLOV (2002-08-30 12:34) [0]Создал объект автоматизации с интерфейсом IMyAuto3 и CoClass MyAuto3. Надо передать этот интерфейс в качестве параметра в след процедуру ScriptControl.AddObject(const Name: WideString; Object_: IDispatch; AddMembers: WordBool);
Попытался в качестве Object_ использовать IMyAuto3, MyAuto3, IMyAuto3Disp - компилятся не хочет:-(.
Как это нужно правильно делать?
Заранее большое спасибо.
Вот описание библиотеи типов:
unit Project1_TLB;
// ************************************************************************ //
// WARNING
// -------
// The types declared in this file were generated from data read from a
// Type Library. If this type library is explicitly or indirectly (via
// another type library referring to this type library) re-imported, or the
// "Refresh" command of the Type Library Editor activated while editing the
// Type Library, the contents of this file will be regenerated and all
// manual modifications will be lost.
// ************************************************************************ //
// PASTLWTR : $Revision: 1.130 $
// File generated on 30.08.2002 12:15:18 from Type Library described below.
// ************************************************************************ //
// Type Lib: D:\Automation Server\Project1.tlb (1)
// LIBID: {C99B9A76-2322-40BB-9875-4D5BB7BC320C}
// LCID: 0
// Helpfile:
// DepndLst:
// (1) v2.0 stdole, (D:\WIN2K\System32\stdole2.tlb)
// (2) v4.0 StdVCL, (D:\WIN2K\System32\stdvcl40.dll)
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
interface
uses ActiveX, Classes, Graphics, StdVCL, Variants, Windows;
// *********************************************************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used:
// Type Libraries : LIBID_xxxx
// CoClasses : CLASS_xxxx
// DISPInterfaces : DIID_xxxx
// Non-DISP interfaces: IID_xxxx
// *********************************************************************//
const
// TypeLibrary Major and minor versions
Project1MajorVersion = 1;
Project1MinorVersion = 0;
LIBID_Project1: TGUID = "{C99B9A76-2322-40BB-9875-4D5BB7BC320C}";
IID_IMyAuto3: TGUID = "{0B2EE616-86E3-4809-91B8-5814A871597E}";
CLASS_MyAuto3: TGUID = "{FF57F52A-6D09-4557-A787-9723367BE0C8}";
type
// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
IMyAuto3 = interface;
IMyAuto3Disp = dispinterface;
// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
MyAuto3 = IMyAuto3;
// Interface: IMyAuto3
// Flags: (6464) Dual OleAutomation Replaceable Dispatchable
// GUID: {0B2EE616-86E3-4809-91B8-5814A871597E}
IMyAuto3 = interface(IDispatch)
["{0B2EE616-86E3-4809-91B8-5814A871597E}"]
procedure AddLine(const Str: WideString); safecall;
function Get_Visible: OleVariant; safecall;
procedure Set_Visible(Value: OleVariant); safecall;
procedure PrintArray(var Arr: OleVariant); safecall;
procedure TryObject(var Obj: OleVariant); safecall;
property Visible: OleVariant read Get_Visible write Set_Visible;
end;
// DispIntf: IMyAuto3Disp
// Flags: (6464) Dual OleAutomation Replaceable Dispatchable
// GUID: {0B2EE616-86E3-4809-91B8-5814A871597E}
IMyAuto3Disp = dispinterface
["{0B2EE616-86E3-4809-91B8-5814A871597E}"]
procedure AddLine(const Str: WideString); dispid 1;
property Visible: OleVariant dispid 7;
procedure PrintArray(var Arr: OleVariant); dispid 2;
procedure TryObject(var Obj: OleVariant); dispid 3;
end;
/The Class CoMyAuto3 provides a Create and CreateRemote method to
// create instances of the default interface IMyAuto3 exposed by
// the CoClass MyAuto3. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
CoMyAuto3 = class
class function Create: IMyAuto3;
class function CreateRemote(const MachineName: string): IMyAuto3;
end;
implementation
uses ComObj;
class function CoMyAuto3.Create: IMyAuto3;
begin
Result := CreateComObject(CLASS_MyAuto3) as IMyAuto3;
end;
class function CoMyAuto3.CreateRemote(const MachineName: string): IMyAuto3;
begin
Result := CreateRemoteComObject(MachineName, CLASS_MyAuto3) as IMyAuto3;
end;
end.
← →
Aleksey Pavlov (2002-08-30 13:04) [1]А зачем передавать интерфейс?
Если вы работаете с автоматизацией, то просто опишите переменную типа IMyAuto3 в private секции класса TForm1 (естественно речь идёт о частном случае).
private
{ Private declarations }
TMyAuto3: IMyAuto3;
Затем, после создания объекта автоматизации, т.е. после:
TMyAuto3:= CreateComObject(CLASS_MyAuto3) as IMyAuto3;
или
TMyAuto3:= CoMyAuto3.Create;
Теперь можете передавать указатель на только что созданный объект автоматизации TMyAuto3.
← →
AFROLOV (2002-08-30 14:22) [2]Большое спасибо за помощь. Все работает.
Страницы: 1 вся ветка
Форум: "Основная";
Текущий архив: 2002.09.12;
Скачать: [xml.tar.bz2];
Память: 0.46 MB
Время: 0.007 c