I have imported a Type Library, which has an interface _IViadabRxEvents which has not had a CoClass defined for it. I am an accomplished Delphi programmer, but I have never really dealt with COM in this way. IF anyone has any suggestions on what to do with the following code to define a CoClass for _IViadabRxEvents?
Thanks for you help in advance.
========================================
unit VIADABRECEIVERLib_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.88 $
// File generated on 21/05/2001 19:37:58 from Type Library described below.
// *************************************************************************//
// NOTE:
// Items guarded by $IFDEF_LIVE_SERVER_AT_DESIGN_TIME are used by properties
// which return objects that may need to be explicitly created via a function
// call prior to any access via the property. These items have been disabled
// in order to prevent accidental use from within the object inspector. You
// may enable them by defining LIVE_SERVER_AT_DESIGN_TIME or by selectively
// removing them from the $IFDEF blocks. However, such items must still be
// programmatically created via a method of the appropriate CoClass before
// they can be used.
// ************************************************************************ //
// Type Lib: C:\Program Files\Common Files\RadioScape\ViadabReceiver.dll (1)
// IID\LCID: {E0EDB401-885F-11D3-982E-00C04F71996F}\0
// Helpfile:
// DepndLst:
// (1) v2.0 stdole, (C:\WINNT\System32\stdole2.tlb)
// (2) v4.0 StdVCL, (C:\WINNT\System32\STDVCL40.DLL)
// Errors:
// Error creating palette bitmap of (TViadabRx) : Invalid GUID format
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers.
interface
uses Windows, ActiveX, Classes, Graphics, OleServer, OleCtrls, StdVCL;
// *********************************************************************//
// 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
VIADABRECEIVERLibMajorVersion = 1;
VIADABRECEIVERLibMinorVersion = 0;
LIBID_VIADABRECEIVERLib: TGUID = '{E0EDB401-885F-11D3-982E-00C04F71996F}';
IID__IViadabRxEvents: TGUID = '{E0EDB412-885F-11D3-982E-00C04F71996F}';
IID_IViadabRx: TGUID = '{E0EDB410-885F-11D3-982E-00C04F71996F}';
CLASS_ViadabRx: TGUID = '{E0EDB411-885F-11D3-982E-00C04F71996F}';
type
// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
_IViadabRxEvents = interface;
IViadabRx = interface;
IViadabRxDisp = dispinterface;
// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
ViadabRx = IViadabRx;
// *********************************************************************//
// Declaration of structures, unions and aliases.
// *********************************************************************//
PByte1 = ^Byte; {*}
// *********************************************************************//
// Interface: _IViadabRxEvents
// Flags: (0)
// GUID: {E0EDB412-885F-11D3-982E-00C04F71996F}
// *********************************************************************//
_IViadabRxEvents = interface(IUnknown)
['{E0EDB412-885F-11D3-982E-00C04F71996F}']
function ReceiverStatusChanged(lFlag: Integer; var data: Byte; lSize: Integer): HResult; stdcall;
function ReceiverData(lComponent: Integer; var data: Byte; lSize: Integer): HResult; stdcall;
end;
// *********************************************************************//
// Interface: IViadabRx
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {E0EDB410-885F-11D3-982E-00C04F71996F}
// *********************************************************************//
IViadabRx = interface(IDispatch)
['{E0EDB410-885F-11D3-982E-00C04F71996F}']
function TuneTo(dMHz: Double): Integer; safecall;
function GetTrackingStatus: Integer; safecall;
function IsTuned: Integer; safecall;
function GetBER: Double; safecall;
function GetEnsemble: Integer; safecall;
function GetFirstService: Integer; safecall;
function GetNextService: Integer; safecall;
function GetFirstComponent(lService: Integer): Integer; safecall;
function GetNextComponent(lService: Integer): Integer; safecall;
function GetDABItemName(lItem: Integer): WideString; safecall;
function IsAudio(lComponent: Integer): Integer; safecall;
function SelectComponent(lComponent: Integer): Integer; safecall;
function DeselectComponent(lComponent: Integer): Integer; safecall;
function IsSelected(lComponent: Integer): Integer; safecall;
function PlayAudio(lComponent: Integer): Integer; safecall;
function StopAudio(lComponent: Integer): Integer; safecall;
function IsPlayingAudio(lComponent: Integer): Integer; safecall;
function GetProgramType(lService: Integer): Integer; safecall;
function GetComponentType(lComponent: Integer): Integer; safecall;
function GetDLS(lComponent: Integer): WideString; safecall;
function GetDABInfo(const Question: WideString): WideString; safecall;
end;
// *********************************************************************//
// DispIntf: IViadabRxDisp
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {E0EDB410-885F-11D3-982E-00C04F71996F}
// *********************************************************************//
IViadabRxDisp = dispinterface
['{E0EDB410-885F-11D3-982E-00C04F71996F}']
function TuneTo(dMHz: Double): Integer; dispid 1;
function GetTrackingStatus: Integer; dispid 2;
function IsTuned: Integer; dispid 3;
function GetBER: Double; dispid 4;
function GetEnsemble: Integer; dispid 5;
function GetFirstService: Integer; dispid 6;
function GetNextService: Integer; dispid 7;
function GetFirstComponent(lService: Integer): Integer; dispid 8;
function GetNextComponent(lService: Integer): Integer; dispid 9;
function GetDABItemName(lItem: Integer): WideString; dispid 10;
function IsAudio(lComponent: Integer): Integer; dispid 11;
function SelectComponent(lComponent: Integer): Integer; dispid 12;
function DeselectComponent(lComponent: Integer): Integer; dispid 13;
function IsSelected(lComponent: Integer): Integer; dispid 14;
function PlayAudio(lComponent: Integer): Integer; dispid 15;
function StopAudio(lComponent: Integer): Integer; dispid 16;
function IsPlayingAudio(lComponent: Integer): Integer; dispid 17;
function GetProgramType(lService: Integer): Integer; dispid 18;
function GetComponentType(lComponent: Integer): Integer; dispid 19;
function GetDLS(lComponent: Integer): WideString; dispid 20;
function GetDABInfo(const Question: WideString): WideString; dispid 21;
end;
// *********************************************************************//
// The Class CoViadabRx provides a Create and CreateRemote method to
// create instances of the default interface IViadabRx exposed by
// the CoClass ViadabRx. The functions are intended to be used by
// clients wishing to automate the CoClass objects exposed by the
// server of this typelibrary.
// *********************************************************************//
CoViadabRx = class
class function Create: IViadabRx;
class function CreateRemote(const MachineName: string): IViadabRx;
end;
TViadabRxReceiverStatusChanged = procedure(Sender: TObject; lFlag: Integer; var data: OleVariant;
lSize: Integer) of object;
TViadabRxReceiverData = procedure(Sender: TObject; lComponent: Integer; var data: OleVariant;
lSize: Integer) of object;
// *********************************************************************//
// OLE Server Proxy class declaration
// Server Object : TViadabRx
// Help String : ViadabRx Class
// Default Interface: IViadabRx
// Def. Intf. DISP? : No
// Event Interface: _IViadabRxEvents
// TypeFlags : (2) CanCreate
// *********************************************************************//
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
TViadabRxProperties= class;
{$ENDIF}
TViadabRx = class(TOleServer)
private
FOnReceiverStatusChanged: TViadabRxReceiverStatusChanged;
FOnReceiverData: TViadabRxReceiverData;
FIntf: IViadabRx;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
FProps: TViadabRxProperties;
function GetServerProperties: TViadabRxProperties;
{$ENDIF}
function GetDefaultInterface: IViadabRx;
protected
procedure InitServerData; override;
procedure InvokeEvent(DispID: TDispID; var Params: TVariantArray); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Connect; override;
procedure ConnectTo(svrIntf: IViadabRx);
procedure Disconnect; override;
function TuneTo(dMHz: Double): Integer;
function GetTrackingStatus: Integer;
function IsTuned: Integer;
function GetBER: Double;
function GetEnsemble: Integer;
function GetFirstService: Integer;
function GetNextService: Integer;
function GetFirstComponent(lService: Integer): Integer;
function GetNextComponent(lService: Integer): Integer;
function GetDABItemName(lItem: Integer): WideString;
function IsAudio(lComponent: Integer): Integer;
function SelectComponent(lComponent: Integer): Integer;
function DeselectComponent(lComponent: Integer): Integer;
function IsSelected(lComponent: Integer): Integer;
function PlayAudio(lComponent: Integer): Integer;
function StopAudio(lComponent: Integer): Integer;
function IsPlayingAudio(lComponent: Integer): Integer;
function GetProgramType(lService: Integer): Integer;
function GetComponentType(lComponent: Integer): Integer;
function GetDLS(lComponent: Integer): WideString;
function GetDABInfo(const Question: WideString): WideString;
property DefaultInterface: IViadabRx read GetDefaultInterface;
published
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
property Server: TViadabRxProperties read GetServerProperties;
{$ENDIF}
property OnReceiverStatusChanged: TViadabRxReceiverStatusChanged read FOnReceiverStatusChanged write FOnReceiverStatusChanged;
property OnReceiverData: TViadabRxReceiverData read FOnReceiverData write FOnReceiverData;
end;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
// *********************************************************************//
// OLE Server Properties Proxy Class
// Server Object : TViadabRx
// (This object is used by the IDE's Property Inspector to allow editing
// of the properties of this server)
// *********************************************************************//
TViadabRxProperties = class(TPersistent)
private
FServer: TViadabRx;
function GetDefaultInterface: IViadabRx;
constructor Create(AServer: TViadabRx);
protected
public
property DefaultInterface: IViadabRx read GetDefaultInterface;
published
end;
{$ENDIF}
procedure Register;
implementation
uses ComObj;
class function CoViadabRx.Create: IViadabRx;
begin
Result := CreateComObject(CLASS_ViadabRx) as IViadabRx;
end;
class function CoViadabRx.CreateRemote(const MachineName: string): IViadabRx;
begin
Result := CreateRemoteComObject(MachineName, CLASS_ViadabRx) as IViadabRx;
end;
procedure TViadabRx.InitServerData;
const
CServerData: TServerData = (
ClassID: '{E0EDB411-885F-11D3-982E-00C04F71996F}';
IntfIID: '{E0EDB410-885F-11D3-982E-00C04F71996F}';
EventIID: '{E0EDB412-885F-11D3-982E-00C04F71996F}';
LicenseKey: nil;
Version: 500);
begin
ServerData := @CServerData;
end;
procedure TViadabRx.Connect;
var
punk: IUnknown;
begin
if FIntf = nil then
begin
punk := GetServer;
ConnectEvents(punk);
Fintf:= punk as IViadabRx;
end;
end;
procedure TViadabRx.ConnectTo(svrIntf: IViadabRx);
begin
Disconnect;
FIntf := svrIntf;
ConnectEvents(FIntf);
end;
procedure TViadabRx.DisConnect;
begin
if Fintf <> nil then
begin
DisconnectEvents(FIntf);
FIntf := nil;
end;
end;
function TViadabRx.GetDefaultInterface: IViadabRx;
begin
if FIntf = nil then
Connect;
Assert(FIntf <> nil, 'DefaultInterface is NULL. Component is not connected to Server. You must call ''Connect'' or ''ConnectTo'' before this operation');
Result := FIntf;
end;
constructor TViadabRx.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
FProps := TViadabRxProperties.Create(Self);
{$ENDIF}
end;
destructor TViadabRx.Destroy;
begin
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
FProps.Free;
{$ENDIF}
inherited Destroy;
end;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
function TViadabRx.GetServerProperties: TViadabRxProperties;
begin
Result := FProps;
end;
{$ENDIF}
procedure TViadabRx.InvokeEvent(DispID: TDispID; var Params: TVariantArray);
begin
case DispID of
-1: Exit; // DISPID_UNKNOWN
1: if Assigned(FOnReceiverStatusChanged) then
FOnReceiverStatusChanged(Self, Params[0] {Integer}, Params[1] {var Byte}, Params[2] {Integer});
2: if Assigned(FOnReceiverData) then
FOnReceiverData(Self, Params[0] {Integer}, Params[1] {var Byte}, Params[2] {Integer});
end; {case DispID}
end;
function TViadabRx.TuneTo(dMHz: Double): Integer;
begin
Result := DefaultInterface.TuneTo(dMHz);
end;
function TViadabRx.GetTrackingStatus: Integer;
begin
Result := DefaultInterface.GetTrackingStatus;
end;
function TViadabRx.IsTuned: Integer;
begin
Result := DefaultInterface.IsTuned;
end;
function TViadabRx.GetBER: Double;
begin
Result := DefaultInterface.GetBER;
end;
function TViadabRx.GetEnsemble: Integer;
begin
Result := DefaultInterface.GetEnsemble;
end;
function TViadabRx.GetFirstService: Integer;
begin
Result := DefaultInterface.GetFirstService;
end;
function TViadabRx.GetNextService: Integer;
begin
Result := DefaultInterface.GetNextService;
end;
function TViadabRx.GetFirstComponent(lService: Integer): Integer;
begin
Result := DefaultInterface.GetFirstComponent(lService);
end;
function TViadabRx.GetNextComponent(lService: Integer): Integer;
begin
Result := DefaultInterface.GetNextComponent(lService);
end;
function TViadabRx.GetDABItemName(lItem: Integer): WideString;
begin
Result := DefaultInterface.GetDABItemName(lItem);
end;
function TViadabRx.IsAudio(lComponent: Integer): Integer;
begin
Result := DefaultInterface.IsAudio(lComponent);
end;
function TViadabRx.SelectComponent(lComponent: Integer): Integer;
begin
Result := DefaultInterface.SelectComponent(lComponent);
end;
function TViadabRx.DeselectComponent(lComponent: Integer): Integer;
begin
Result := DefaultInterface.DeselectComponent(lComponent);
end;
function TViadabRx.IsSelected(lComponent: Integer): Integer;
begin
Result := DefaultInterface.IsSelected(lComponent);
end;
function TViadabRx.PlayAudio(lComponent: Integer): Integer;
begin
Result := DefaultInterface.PlayAudio(lComponent);
end;
function TViadabRx.StopAudio(lComponent: Integer): Integer;
begin
Result := DefaultInterface.StopAudio(lComponent);
end;
function TViadabRx.IsPlayingAudio(lComponent: Integer): Integer;
begin
Result := DefaultInterface.IsPlayingAudio(lComponent);
end;
function TViadabRx.GetProgramType(lService: Integer): Integer;
begin
Result := DefaultInterface.GetProgramType(lService);
end;
function TViadabRx.GetComponentType(lComponent: Integer): Integer;
begin
Result := DefaultInterface.GetComponentType(lComponent);
end;
function TViadabRx.GetDLS(lComponent: Integer): WideString;
begin
Result := DefaultInterface.GetDLS(lComponent);
end;
function TViadabRx.GetDABInfo(const Question: WideString): WideString;
begin
Result := DefaultInterface.GetDABInfo(Question);
end;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
constructor TViadabRxProperties.Create(AServer: TViadabRx);
begin
inherited Create;
FServer := AServer;
end;
function TViadabRxProperties.GetDefaultInterface: IViadabRx;
begin
Result := FServer.DefaultInterface;
end;
{$ENDIF}
procedure Register;
begin
RegisterComponents('RadioScape',[TViadabRx]);
end;
end.
========================================
Thanks
Gordon ALLAN
