TDCOMConnection的繼承關系為:
TDCOMConnction-->TCOMConnection-->TDispatchConnection
在TDispatchConnection中有一個GetServerList私有方法.因此可以重新聲明一個類,
將GetServerList方法引出,以供調用.
unit MyConnection
interface
uses
MConnect;
type
TMyConn=Class(TDispatchConnection)
public function MyGetServerList:OleVariant;
end;
implementation
{ TMyConn }
function TMyConn.MyGetServerList: OleVariant;
begin
Result:=GetServerList;
end;
//使用:
procedure TForm1.Button1Click(Sender: TObject);
var
V:OleVariant;
I:Integer;
begin
V:=TMyConn(DComConnection1).MyGetServerList;
for I:=VarArrayLowBound(V,1) to VarArrayHighBound(V,1)do
ListBox1.Items.Add(V);
end;