赶紧来帮忙:讨厌的tlb(100分)

  • 主题发起人 主题发起人 lgw_1
  • 开始时间 开始时间
L

lgw_1

Unregistered / Unconfirmed
GUEST, unregistred user!
大家好:
小弟不才.现在有个问题:
别人已经提供了ole server,有个 .tlb的库文件如cca.tlb(是库文件吧?)
我已经在project->import type library 中加入的它(cca.tlb), 然后生
成了cca_tlb.pas.但剩下来就不知如何是好: uses cca_tlb之后如何去声
明和读取它里面的object . 本来已经有了一个demo是用vb 写的:
工程->进用
Public WithEvents CCAServer As CCAOleServ
Public WithEvents CAgentPhone As AgentPhone
Public WithEvents CAgentStatistics As AgentStatistics
set CCAServer = CreateObject("CCA.CCAOleServ")
Set CAgentPhone = CreateObject("CCA.AgentPhone")
Set CAgentStatistics = CreateObject("CCA.AgentStatistics")
....
可是小弟极力反对VB,而想用delphi 可现在技不如人,特向大家求教,
希望能给个例子(小小的也好).否则下个星期一就......
 
如果你的。tlb已经注册,后面的方法与VB类似。
 
大致可能应该是
var
CCAServer:ICCAOleServ;
CAgentPhone:IAgentPhone;
CAgentStatistics:IAgentStatistics;
//或者是CCAServer:olevariant;
...
begin
CCAServer := CreateObject("CCA.CCAOleServ") as ICCAOleServ;
CAgentPhone := CreateObject("CCA.AgentPhone") as IAgentPhone;
CAgentStatistics := CreateObject("CCA.AgentStatistics") as IAgentStatistics;
//或者是CCAServer :=CreateObject("CCA.CCAOleServ");
.....
end;
最好把你的cca_tlb.pas 和 vb贴全一点出来看看。

 
现在只需要去控件板上的 ActiveX 上找到这几个控件,放到你的窗口上就可以用了
 
大家好:
现我将cca_tlb.pas贴出来了:
unit CCA_TLB;
interface

uses Windows, ActiveX, Classes, Graphics, 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
LIBID_CCA: TGUID = '{0670A181-76C3-11D1-B03F-00A024C4B31A}';
DIID_ICCAOleServ: TGUID = '{B99E63F1-8F09-11D1-9072-006008719609}';
DIID_ICCAOleServEvents: TGUID = '{B99E63F3-8F09-11D1-9072-006008719609}';
CLASS_CCAOleServ: TGUID = '{B99E63F2-8F09-11D1-9072-006008719609}';
DIID_IAgentPhone: TGUID = '{B99E6414-8F09-11D1-9072-006008719609}';
DIID_IAgentPhoneEvents: TGUID = '{B99E6418-8F09-11D1-9072-006008719609}';
CLASS_AgentPhone: TGUID = '{B99E6416-8F09-11D1-9072-006008719609}';
DIID_IAgentStatistics: TGUID = '{A4BE6396-925B-11D1-9072-006008719609}';
DIID_IAgentStatisticsEvents: TGUID = '{A4BE639A-925B-11D1-9072-006008719609}';
CLASS_AgentStatistics: TGUID = '{A4BE6398-925B-11D1-9072-006008719609}';
type

// *********************************************************************//
// Forward declaration of interfaces defined in Type Library //
// *********************************************************************//
ICCAOleServ = dispinterface;
ICCAOleServEvents = dispinterface;
IAgentPhone = dispinterface;
IAgentPhoneEvents = dispinterface;
IAgentStatistics = dispinterface;
IAgentStatisticsEvents = dispinterface;

// *********************************************************************//
// Declaration of CoClasses defined in Type Library //
// (NOTE: Here we map each CoClass to its Default Interface) //
// *********************************************************************//
CCAOleServ = ICCAOleServ;
AgentPhone = IAgentPhone;
AgentStatistics = IAgentStatistics;

// *********************************************************************//
// DispIntf: ICCAOleServ
// Flags: (4096) Dispatchable
// GUID: {B99E63F1-8F09-11D1-9072-006008719609}
// *********************************************************************//
ICCAOleServ = dispinterface
['{B99E63F1-8F09-11D1-9072-006008719609}']
property Visible: Smallint dispid 2;
property CCATime: Integer dispid 3;
property PhoneServerOK: WordBool dispid 5;
function XShell(const AppName: WideString; const CmdLine: WideString): WordBool; dispid 103;
function XDDEInitiate(const AppName: WideString; const Topic: WideString): Integer; dispid 104;

end;

// *********************************************************************//
// DispIntf: ICCAOleServEvents
// Flags: (4096) Dispatchable
// GUID: {B99E63F3-8F09-11D1-9072-006008719609}
// *********************************************************************//
ICCAOleServEvents = dispinterface
['{B99E63F3-8F09-11D1-9072-006008719609}']
procedure OnQuit; dispid 1;
procedure OnVisible(Windows: Smallint); dispid 2;
procedure OnServersStatus(Status: Smallint); dispid 3;
procedure OnXDelay(DelayID: Integer); dispid 4;
end;

// *********************************************************************//
// DispIntf: IAgentPhone
// Flags: (4096) Dispatchable
// GUID: {B99E6414-8F09-11D1-9072-006008719609}
// *********************************************************************//
IAgentPhone = dispinterface
['{B99E6414-8F09-11D1-9072-006008719609}']
property Extension: WideString dispid 1;
property LoggedAgent: WideString dispid 2;
property LoggedTeam: WideString dispid 3;

function AgentLogon(const Agent: WideString; const Team: WideString; const Password: WideString): WordBool; dispid 100;
function AgentLogoff(const Agent: WideString; const Team: WideString; const Password: WideString): WordBool; dispid 101;
function AlternateCall: WordBool; dispid 102;
function AnswerCall: WordBool; dispid 103;
…..
property LocalCallState[nConnection: Smallint]: Smallint dispid 200;
property CallingDevice[nConnection: Smallint]: WideString dispid 201;
end;
 
那你现在可以这样写:
var
ACCAServer:ICCAOleServ;
AAgentPhone:IAgentPhone;
AAgentStatistics:IAgentStatistics;
begin
ACCAServer := CreateComObject(CLASS_AgentPhone) as ICCAOleServ;
AAgentPhone := CreateComObject(CLASS_AgentPhone) as IAgentPhone;
AAgentStatistics := CreateComObject(CLASS_AgentStatistics) as IAgentStatistics;
....
接下来就可以调用借口函数和属性了,比如
showmessage(inttostr(ACCAServer.CCATime));
等等
end;
 
重谢hubdog!!!
对了,pipi说的在ActiveX里能找到,可我为什么看不到?
 
是不是pipi说的是在component->import activeX control 中加入.OCX以后,
就能在控件板上的 ActiveX 上找到这几个控件的?
 
不是所有的oleserver都能在activex中找到对应的封装,
你的这个tlb就没有,有的话,应该是有类似这样的语句
t***=class(toleserver)
....
end;
别费劲了,hehe,给分吧
 
请大侠笑纳,下次还望相助.
 
后退
顶部