IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

January Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyPascal and Delphi Coding BoardDelphi COM / ActiveX / DCOM Topic   Print This     

Creating un imported CoClass Routines

Creating un imported CoClass Routines in Delphi COM / ActiveX / DCOM topic (part of our Pascal and Delphi Coding group).

Quick Search: Creating   imported   CoClass   Routines   Creating un   Creating un imported   CoClass Routines  
gordon
 (Inactive)
-- USA
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 Big Grin! Confused
 Posted 21 years ago (Thread Starter)
Comment Quote
About gordon -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #2242, 3 replies
Thread Started 5/21/2001 10:29:00 PM
View Counter=3060
Last Reply Posted 5/23/2001 9:45:00 PM)
Location=-- USA 
Joined=21 years ago   MB Posts=23  
Larry J. Rutledge
Prestwood IT
Citrus Heights, CA USA
A good reference that can probably provide you with the answers you need is the book, [u]Delphi COM Programming[/u] by Eric Harmon, published by Macmillan Technical Publishing (ISBN: 1-57870-221-6).

It is an excellent book covering all aspects of COM programming, and specifically how to implement it with Delphi.

Hope this helps,
Larry J. Rutledge
Larry J. Rutledge

Analyst

Prestwood Software

www.prestwood.com
 Posted 21 years ago
Comment Quote
About Larry J. Rutledge -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About Larry J. Rutledge
I worked for Prestwood Software as a Delphi developer from 1997 through 2002. During that time I enjoyed working with Mike Prestwood and the other developers at Prestwood.

Post ID #2261 (Level 1.1)  Reply to 2242
Thread Started 5/23/2001 11:17:00 AM
View Counter=2
Location=Citrus Heights, CA USA 
Joined=22 years ago   MB Posts=73   KB Posts=9  
gordon
 (Inactive)
-- USA
Thanks for your sugeestion, I have put the book on order and I shoul get it in the next few weeks, no-one had it in stock. I really need to get started on this.

Does anyone have any good ideas? On how to start. After discussion with the original Programming team, I need to find a connection point on the IViadabRx to point to the _IViadabRxEvents. Hopefully this book will help, but any thoughts in the meantime?

Thanks

Gordon Confused
 Posted 21 years ago (Thread Starter)
Comment Quote
About gordon -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #2267 (Level 1.2)  Reply to 2242
Reply Posted 5/23/2001 9:38:00 PM
Location=-- USA 
Joined=21 years ago   MB Posts=23  
Most Recent Post
gordon
 (Inactive)
-- USA
I forgot to mention, that If I could get the component wrapper to work properly, then this problem would be solved. It works and compiles, but when you call the Connect Routine, the compiler throws up an error on the oleserver file to do with a Count Variable in a subroutine, is this a known problem? or not?

I do use a variable called Count in my application, but I did a simple application with that one component on and when I asked to connect it threw up the same error. I cannot rememeber the subroutine right now, but when I get back to my machine later on, I will let you know.

I hav not yet installed the D5 Update yet. Will this help?

Thanks

Gordon Confused
 Posted 21 years ago (Thread Starter)
Comment Quote
About gordon -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #2268 (Level 1.3)  Reply to 2242
Reply Posted 5/23/2001 9:45:00 PM
Location=-- USA 
Joined=21 years ago   MB Posts=23  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1183A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #2242 Counter
3060
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2022 Prestwood IT Solutions.   [Security & Privacy]