要用到如下的单元文件RTXClient_TLB.pas:
这个文件可以在delphi2010里在component菜单里产生:
unit RTXClient_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. //
************************************************************************
//
// $Rev: 17244 $
// File generated on 2011-2-1 AM 11:37:01 from Type Library
described below.
//
************************************************************************ //
// Type Lib: C:\Program Files\Tencent\RTXC\RTXAX.dll (1)
// LIBID: {22346CAA-2CC6-436A-AB1F-CFDB62F237F5}
// LCID: 0
// Helpfile:
// HelpString: RTXAX 1.0 Type Library
// DepndLst:
// (1) v2.0 stdole,
(C:\WINDOWS\system32\stdole2.tlb)
//
************************************************************************
//
//
*************************************************************************//
//
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. {$TYPEDADDRESS OFF} // Unit must be compiled without type-checked
pointers.
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
{$ALIGN 4}
interface
uses Windows, ActiveX, Classes, Graphics, OleCtrls, OleServer,
StdVCL, Variants;
//
*********************************************************************//
// 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
RTXClientMajorVersion = 1;
RTXClientMinorVersion = 0;
LIBID_RTXClient: TGUID =
'{22346CAA-2CC6-436A-AB1F-CFDB62F237F5}';
DIID__IRTXAPIEvents: TGUID =
'{645ABB71-7610-4679-9066-8935A6BB098E}';
IID_IRTXAPI: TGUID =
'{9C415AA6-E346-43B8-ADA8-EACD080235A4}';
CLASS_RTXAPI: TGUID =
'{5EEEA87D-160E-4A2D-8427-B6C333FEDA4D}';
type
//
*********************************************************************//
// Forward declaration of types defined in
TypeLibrary //
*********************************************************************//
_IRTXAPIEvents = dispinterface;
IRTXAPI = interface;
IRTXAPIDisp = dispinterface;
//
*********************************************************************//
// Declaration of CoClasses defined in Type
Library // (NOTE: Here we map each CoClass to its Default
Interface) //
*********************************************************************//
RTXAPI = IRTXAPI;
//
*********************************************************************//
// DispIntf: _IRTXAPIEvents
//
Flags: (4096) Dispatchable
//
GUID: {645ABB71-7610-4679-9066-8935A6BB098E}
//
*********************************************************************//
_IRTXAPIEvents = dispinterface
['{645ABB71-7610-4679-9066-8935A6BB098E}']
procedure
OnEvent(vObjectID: OleVariant; lEvent: Integer; vProperty:
OleVariant); dispid 1;
end;
//
*********************************************************************//
// Interface: IRTXAPI
//
Flags: (4416) Dual OleAutomation Dispatchable
//
GUID: {9C415AA6-E346-43B8-ADA8-EACD080235A4}
//
*********************************************************************//
IRTXAPI = interface(IDispatch)
['{9C415AA6-E346-43B8-ADA8-EACD080235A4}']
function
GetObject(vObjectID: OleVariant): IDispatch; safecall;
function
Call(lID: Integer; vProperty: OleVariant): OleVariant;
safecall;
function
Get_EventFilter(vObjectID: OleVariant): Integer; safecall;
procedure
Set_EventFilter(vObjectID: OleVariant; pVal: Integer);
safecall;
function
Get_URL: WideString; safecall;
procedure
Set_URL(const pVal: WideString); safecall;
procedure
StartInstall; safecall;
function
IsInstalled: WordBool; safecall;
function
IsRTXCRunning: WordBool; safecall;
function
SetFrameMiniSize: WordBool; safecall;
property
EventFilter[vObjectID: OleVariant]: Integer read Get_EventFilter
write Set_EventFilter;
property
URL: WideString read Get_URL write Set_URL;
end;
//
*********************************************************************//
// DispIntf: IRTXAPIDisp
//
Flags: (4416) Dual OleAutomation Dispatchable
//
GUID: {9C415AA6-E346-43B8-ADA8-EACD080235A4}
//
*********************************************************************//
IRTXAPIDisp = dispinterface
['{9C415AA6-E346-43B8-ADA8-EACD080235A4}']
function
GetObject(vObjectID: OleVariant): IDispatch; dispid 1;
function
Call(lID: Integer; vProperty: OleVariant): OleVariant; dispid
2;
property
EventFilter[vObjectID: OleVariant]: Integer dispid 3;
property
URL: WideString dispid 4;
procedure
StartInstall; dispid 5;
function
IsInstalled: WordBool; dispid 6;
function
IsRTXCRunning: WordBool; dispid 7;
function
SetFrameMiniSize: WordBool; dispid 8;
end;
//
*********************************************************************//
// OLE Control Proxy class declaration
// Control
Name : TRTXAPI
// Help
String : RTXClient Class
// Default Interface: IRTXAPI
// Def. Intf. DISP? : No
// Event Interface:
_IRTXAPIEvents
//
TypeFlags : (2) CanCreate
//
*********************************************************************//
TRTXAPIOnEvent = procedure(ASender: TObject;
vObjectID: OleVariant; lEvent: Integer;
vProperty: OleVariant) of object;
TRTXAPI = class(TOleControl)
private
FOnEvent:
TRTXAPIOnEvent;
FIntf:
IRTXAPI;
function GetControlInterface: IRTXAPI;
protected
procedure
CreateControl;
procedure
InitControlData; override;
function
Get_EventFilter(vObjectID: OleVariant): Integer;
procedure
Set_EventFilter(vObjectID: OleVariant; pVal: Integer);
public
function
GetObject(vObjectID: OleVariant): IDispatch;
function
Call(lID: Integer; vProperty: OleVariant): OleVariant;
procedure
StartInstall;
function
IsInstalled: WordBool;
function
IsRTXCRunning: WordBool;
function
SetFrameMiniSize: WordBool;
property ControlInterface: IRTXAPI read
GetControlInterface;
property DefaultInterface: IRTXAPI read
GetControlInterface;
property
EventFilter[vObjectID: OleVariant]: Integer read Get_EventFilter
write Set_EventFilter;
published
property
Anchors;
property TabStop;
property Align;
property DragCursor;
property DragMode;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property Visible;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnStartDrag;
property
URL: WideString index 4 read GetWideStringProp write
SetWideStringProp stored False;
property
OnEvent: TRTXAPIOnEvent read FOnEvent write FOnEvent;
end;
procedure Register;
resourcestring
dtlServerPage = 'ActiveX';
dtlOcxPage = 'ActiveX';
implementation
uses ComObj;
procedure TRTXAPI.InitControlData;
const
CEventDispIDs: array [0..0] of DWORD = (
$00000001);
CControlData: TControlData2 = (
ClassID:
'{5EEEA87D-160E-4A2D-8427-B6C333FEDA4D}';
EventIID:
'{645ABB71-7610-4679-9066-8935A6BB098E}';
EventCount:
1;
EventDispIDs: @CEventDispIDs;
LicenseKey:
nil (*HR:$80004002*);
Flags:
$00000000;
Version:
401);
begin
ControlData := @CControlData;
TControlData2(CControlData).FirstEventOfs :=
Cardinal(@@FOnEvent) - Cardinal(Self);
end;
procedure TRTXAPI.CreateControl;
procedure DoCreate;
begin
FIntf :=
IUnknown(OleObject) as IRTXAPI;
end;
begin
if FIntf = nil then DoCreate;
end;
function TRTXAPI.GetControlInterface: IRTXAPI;
begin
CreateControl;
Result := FIntf;
end;
function TRTXAPI.Get_EventFilter(vObjectID: OleVariant):
Integer;
begin
Result :=
DefaultInterface.EventFilter[vObjectID];
end;
procedure TRTXAPI.Set_EventFilter(vObjectID: OleVariant; pVal:
Integer);
begin
DefaultInterface.EventFilter[vObjectID] :=
pVal;
end;
function TRTXAPI.GetObject(vObjectID: OleVariant):
IDispatch;
begin
Result :=
DefaultInterface.GetObject(vObjectID);
end;
function TRTXAPI.Call(lID: Integer; vProperty: OleVariant):
OleVariant;
begin
Result := DefaultInterface.Call(lID,
vProperty);
end;
procedure TRTXAPI.StartInstall;
begin
DefaultInterface.StartInstall;
end;
function TRTXAPI.IsInstalled: WordBool;
begin
Result := DefaultInterface.IsInstalled;
end;
function TRTXAPI.IsRTXCRunning: WordBool;
begin
Result := DefaultInterface.IsRTXCRunning;
end;
function TRTXAPI.SetFrameMiniSize: WordBool;
begin
Result :=
DefaultInterface.SetFrameMiniSize;
end;
procedure Register;
begin
RegisterComponents(dtlOcxPage, [TRTXAPI]);
end;
end.
在delphi2010程序中引用RTXClient_TLB单元:
uses ... RTXClient_TLB ...
procedure TForm1.Button1Click(Sender: TObject);
var
oo:Trtxapi;
obj:olevariant;
begin
oo:=trtxapi.Create(self);
obj:= oo.GetObject('kernalroot') ;
showmessage(obj.account );
end;