VC的COM,DELPHI中调用.(200)

  • 主题发起人 主题发起人 forall
  • 开始时间 开始时间
F

forall

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Eterm3Lib_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 : 1.2// File generated on 2010-11-10 20:58:57 from Type Library described below.// ************************************************************************ //// Type Lib: C:/Program Files/TravelSky/eTerm3/eTerm3.tlb (1)// LIBID: {3B06E499-1473-47ED-85A5-2CE4EE45A6DF}// LCID: 0// Helpfile: // HelpString: Eterm3 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}interfaceuses Windows, ActiveX, Classes, Graphics, 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 Eterm3LibMajorVersion = 1; Eterm3LibMinorVersion = 0; LIBID_Eterm3Lib: TGUID = '{3B06E499-1473-47ED-85A5-2CE4EE45A6DF}'; DIID__IApplicationEvents: TGUID = '{3C31BF76-2837-4BFA-A19E-34485A213F29}'; DIID__ISessionEvents: TGUID = '{4ADE78EF-390A-4FF8-B788-C47E30331B6D}'; IID_ISession: TGUID = '{2F4B1CA9-0DF8-4EC8-92DF-71BACE1DE0AA}'; CLASS_Session: TGUID = '{EC2C9F4C-CFB4-4096-AFC0-1531FC603606}'; IID_ISessions: TGUID = '{74423526-1E08-4A97-BC85-2D5FCC22CDBE}'; CLASS_Sessions: TGUID = '{FE104F26-4219-4DE0-87B9-8FF12A2A56B1}'; IID_IApplication: TGUID = '{98AA9DD3-0715-4170-8A96-04F06C8BAD49}'; CLASS_Application: TGUID = '{C5E9A707-5D62-4C96-A1B0-3DA8B719AA0D}';type// *********************************************************************//// Forward declaration of types defined in TypeLibrary // *********************************************************************// _IApplicationEvents = dispinterface; _ISessionEvents = dispinterface; ISession = interface; ISessionDisp = dispinterface; ISessions = interface; ISessionsDisp = dispinterface; IApplication = interface; IApplicationDisp = dispinterface;// *********************************************************************//// Declaration of CoClasses defined in Type Library // (NOTE: Here we map each CoClass to its Default Interface) // *********************************************************************// Session = ISession; Sessions = ISessions; Application = IApplication;// *********************************************************************//// Declaration of structures, unions and aliases. // *********************************************************************// POleVariant1 = ^OleVariant; {*}// *********************************************************************//// DispIntf: _IApplicationEvents// Flags: (4096) Dispatchable// GUID: {3C31BF76-2837-4BFA-A19E-34485A213F29}// *********************************************************************// _IApplicationEvents = dispinterface ['{3C31BF76-2837-4BFA-A19E-34485A213F29}'] procedure ReceiveCurConf(var Conf: OleVariant); dispid 1; procedure StatusChange(Status: Integer; const bstrDetail: WideString); dispid 2; end;// *********************************************************************//// DispIntf: _ISessionEvents// Flags: (4096) Dispatchable// GUID: {4ADE78EF-390A-4FF8-B788-C47E30331B6D}// *********************************************************************// _ISessionEvents = dispinterface ['{4ADE78EF-390A-4FF8-B788-C47E30331B6D}'] procedure CPReceive(H1: Smallint; H2: Smallint; shReceiveType: Smallint; X: Smallint; Y: Smallint; const bstrReceived: WideString); dispid 1; end;// *********************************************************************//// Interface: ISession// Flags: (4416) Dual OleAutomation Dispatchable// GUID: {2F4B1CA9-0DF8-4EC8-92DF-71BACE1DE0AA}// *********************************************************************// ISession = interface(IDispatch) ['{2F4B1CA9-0DF8-4EC8-92DF-71BACE1DE0AA}'] procedure InputStr(shH1: Smallint; shH2: Smallint; shSID: Smallint; const bstrCmd: WideString); safecall; procedure SendStrNow(shH1: Smallint; shH2: Smallint; shSID: Smallint; const bstrCmd: WideString); safecall; procedure SendCmd(shH1: Smallint; shH2: Smallint; shSID: Smallint; X: Smallint; Y: Smallint; shKey: Smallint); safecall; procedure PrintData(PrinterType: Integer; const PrinterInfo: WideString); safecall; function GetLockStatus: Smallint; safecall; procedure GetH1(out H1: Smallint); safecall; procedure GetH2(out H2: Smallint); safecall; procedure GetRID(out RID: Smallint); safecall; procedure GetSID(out SID: Smallint); safecall; procedure FullScreenString(Data: OleVariant); safecall; function GetCurrentSessionID: Integer; safecall; procedure Lock; safecall; procedure Unlock; safecall; function IsLock: Integer; safecall; function Get_nRow: Smallint; safecall; procedure Set_nRow(pVal: Smallint); safecall; function Get_nCol: Smallint; safecall; procedure Set_nCol(pVal: Smallint); safecall; property nRow: Smallint read Get_nRow write Set_nRow; property nCol: Smallint read Get_nCol write Set_nCol; end;// *********************************************************************//// DispIntf: ISessionDisp// Flags: (4416) Dual OleAutomation Dispatchable// GUID: {2F4B1CA9-0DF8-4EC8-92DF-71BACE1DE0AA}// *********************************************************************// ISessionDisp = dispinterface ['{2F4B1CA9-0DF8-4EC8-92DF-71BACE1DE0AA}'] procedure InputStr(shH1: Smallint; shH2: Smallint; shSID: Smallint; const bstrCmd: WideString); dispid 1; procedure SendStrNow(shH1: Smallint; shH2: Smallint; shSID: Smallint; const bstrCmd: WideString); dispid 2; procedure SendCmd(shH1: Smallint; shH2: Smallint; shSID: Smallint; X: Smallint; Y: Smallint; shKey: Smallint); dispid 3; procedure PrintData(PrinterType: Integer; const PrinterInfo: WideString); dispid 4; function GetLockStatus: Smallint; dispid 5; procedure GetH1(out H1: Smallint); dispid 6; procedure GetH2(out H2: Smallint); dispid 7; procedure GetRID(out RID: Smallint); dispid 8; procedure GetSID(out SID: Smallint); dispid 9; procedure FullScreenString(Data: OleVariant); dispid 10; function GetCurrentSessionID: Integer; dispid 11; procedure Lock; dispid 12; procedure Unlock; dispid 13; function IsLock: Integer; dispid 14; property nRow: Smallint dispid 15; property nCol: Smallint dispid 16; end;// *********************************************************************//// Interface: ISessions// Flags: (4416) Dual OleAutomation Dispatchable// GUID: {74423526-1E08-4A97-BC85-2D5FCC22CDBE}// *********************************************************************// ISessions = interface(IDispatch) ['{74423526-1E08-4A97-BC85-2D5FCC22CDBE}'] function Count: Integer; safecall; function Item(index: OleVariant): IDispatch; safecall; function GetTotalSessionNumber: Integer; safecall; function GetActiveSession: Integer; safecall; function Get__NewEnum: IUnknown; safecall; property _NewEnum: IUnknown read Get__NewEnum; end;// *********************************************************************//// DispIntf: ISessionsDisp// Flags: (4416) Dual OleAutomation Dispatchable// GUID: {74423526-1E08-4A97-BC85-2D5FCC22CDBE}// *********************************************************************// ISessionsDisp = dispinterface ['{74423526-1E08-4A97-BC85-2D5FCC22CDBE}'] function Count: Integer; dispid 1; function Item(index: OleVariant): IDispatch; dispid 2; function GetTotalSessionNumber: Integer; dispid 3; function GetActiveSession: Integer; dispid 4; property _NewEnum: IUnknown readonly dispid -4; end;// *********************************************************************//// Interface: IApplication// Flags: (4416) Dual OleAutomation Dispatchable// GUID: {98AA9DD3-0715-4170-8A96-04F06C8BAD49}// *********************************************************************// IApplication = interface(IDispatch) ['{98AA9DD3-0715-4170-8A96-04F06C8BAD49}'] procedure Connect(shType: Smallint; const bstrServerIP: WideString; const bstrUser: WideString; const bstrPass: WideString); safecall; procedure DisConnect; safecall; function IsConnect: Smallint; safecall; function GetSessions: IDispatch; safecall; procedure Exit; safecall; procedure ShowServer; safecall; function GetCurrentAccount: WideString; safecall; function GetCurrentHost: WideString; safecall; end;// *********************************************************************//// DispIntf: IApplicationDisp// Flags: (4416) Dual OleAutomation Dispatchable// GUID: {98AA9DD3-0715-4170-8A96-04F06C8BAD49}// *********************************************************************// IApplicationDisp = dispinterface ['{98AA9DD3-0715-4170-8A96-04F06C8BAD49}'] procedure Connect(shType: Smallint; const bstrServerIP: WideString; const bstrUser: WideString; const bstrPass: WideString); dispid 1; procedure DisConnect; dispid 2; function IsConnect: Smallint; dispid 3; function GetSessions: IDispatch; dispid 4; procedure Exit; dispid 5; procedure ShowServer; dispid 6; function GetCurrentAccount: WideString; dispid 7; function GetCurrentHost: WideString; dispid 8; end;// *********************************************************************//// The Class CoSession provides a Create and CreateRemote method to // create instances of the default interface ISession exposed by // the CoClass Session. The functions are intended to be used by // clients wishing to automate the CoClass objects exposed by the // server of this typelibrary. // *********************************************************************// CoSession = class class function Create: ISession; class function CreateRemote(const MachineName: string): ISession; end; TSession1CPReceive = procedure(ASender: TObject; H1: Smallint; H2: Smallint; shReceiveType: Smallint; X: Smallint; Y: Smallint; const bstrReceived: WideString) of object;// *********************************************************************//// OLE Server Proxy class declaration// Server Object : TSession1// Help String : Session Class// Default Interface: ISession// Def. Intf. DISP? : No// Event Interface: _ISessionEvents// TypeFlags : (2) CanCreate// *********************************************************************//{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} TSession1Properties= class;{$ENDIF} TSession1 = class(TOleServer) private FOnCPReceive: TSession1CPReceive; FIntf: ISession;{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps: TSession1Properties; function GetServerProperties: TSession1Properties;{$ENDIF} function GetDefaultInterface: ISession; protected procedure InitServerData; override; procedure InvokeEvent(DispID: TDispID; var Params: TVariantArray); override; function Get_nRow: Smallint; procedure Set_nRow(pVal: Smallint); function Get_nCol: Smallint; procedure Set_nCol(pVal: Smallint); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Connect; override; procedure ConnectTo(svrIntf: ISession); procedure Disconnect; override; procedure InputStr(shH1: Smallint; shH2: Smallint; shSID: Smallint; const bstrCmd: WideString); procedure SendStrNow(shH1: Smallint; shH2: Smallint; shSID: Smallint; const bstrCmd: WideString); procedure SendCmd(shH1: Smallint; shH2: Smallint; shSID: Smallint; X: Smallint; Y: Smallint; shKey: Smallint); procedure PrintData(PrinterType: Integer; const PrinterInfo: WideString); function GetLockStatus: Smallint; procedure GetH1(out H1: Smallint); procedure GetH2(out H2: Smallint); procedure GetRID(out RID: Smallint); procedure GetSID(out SID: Smallint); procedure FullScreenString(Data: OleVariant); function GetCurrentSessionID: Integer; procedure Lock; procedure Unlock; function IsLock: Integer; property DefaultInterface: ISession read GetDefaultInterface; property nRow: Smallint read Get_nRow write Set_nRow; property nCol: Smallint read Get_nCol write Set_nCol; published{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} property Server: TSession1Properties read GetServerProperties;{$ENDIF} property OnCPReceive: TSession1CPReceive read FOnCPReceive write FOnCPReceive; end;{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}// *********************************************************************//// OLE Server Properties Proxy Class// Server Object : TSession1// (This object is used by the IDE's Property Inspector to allow editing// of the properties of this server)// *********************************************************************// TSession1Properties = class(TPersistent) private FServer: TSession1; function GetDefaultInterface: ISession; constructor Create(AServer: TSession1); protected function Get_nRow: Smallint; procedure Set_nRow(pVal: Smallint); function Get_nCol: Smallint; procedure Set_nCol(pVal: Smallint); public property DefaultInterface: ISession read GetDefaultInterface; published property nRow: Smallint read Get_nRow write Set_nRow; property nCol: Smallint read Get_nCol write Set_nCol; end;{$ENDIF}// *********************************************************************//// The Class CoSessions provides a Create and CreateRemote method to // create instances of the default interface ISessions exposed by // the CoClass Sessions. The functions are intended to be used by // clients wishing to automate the CoClass objects exposed by the // server of this typelibrary. // *********************************************************************// CoSessions = class class function Create: ISessions; class function CreateRemote(const MachineName: string): ISessions; end;// *********************************************************************//// OLE Server Proxy class declaration// Server Object : TSessions1// Help String : Sessions Class// Default Interface: ISessions// Def. Intf. DISP? : No// Event Interface: // TypeFlags : (2) CanCreate// *********************************************************************//{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} TSessions1Properties= class;{$ENDIF} TSessions1 = class(TOleServer) private FIntf: ISessions;{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps: TSessions1Properties; function GetServerProperties: TSessions1Properties;{$ENDIF} function GetDefaultInterface: ISessions; protected procedure InitServerData; override; function Get__NewEnum: IUnknown; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Connect; override; procedure ConnectTo(svrIntf: ISessions); procedure Disconnect; override; function Count: Integer; function Item(index: OleVariant): IDispatch; function GetTotalSessionNumber: Integer; function GetActiveSession: Integer; property DefaultInterface: ISessions read GetDefaultInterface; property _NewEnum: IUnknown read Get__NewEnum; published{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} property Server: TSessions1Properties read GetServerProperties;{$ENDIF} end;{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}// *********************************************************************//// OLE Server Properties Proxy Class// Server Object : TSessions1// (This object is used by the IDE's Property Inspector to allow editing// of the properties of this server)// *********************************************************************// TSessions1Properties = class(TPersistent) private FServer: TSessions1; function GetDefaultInterface: ISessions; constructor Create(AServer: TSessions1); protected function Get__NewEnum: IUnknown; public property DefaultInterface: ISessions read GetDefaultInterface; published end;{$ENDIF}// *********************************************************************//// The Class CoApplication provides a Create and CreateRemote method to // create instances of the default interface IApplication exposed by // the CoClass Application. The functions are intended to be used by // clients wishing to automate the CoClass objects exposed by the // server of this typelibrary. // *********************************************************************// CoApplication = class class function Create: IApplication; class function CreateRemote(const MachineName: string): IApplication; end; TApplication1ReceiveCurConf = procedure(ASender: TObject; var Conf: OleVariant) of object; TApplication1StatusChange = procedure(ASender: TObject; Status: Integer; const bstrDetail: WideString) of object;// *********************************************************************//// OLE Server Proxy class declaration// Server Object : TApplication1// Help String : Application Class// Default Interface: IApplication// Def. Intf. DISP? : No// Event Interface: _IApplicationEvents// TypeFlags : (2) CanCreate// *********************************************************************//{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} TApplication1Properties= class;{$ENDIF} TApplication1 = class(TOleServer) private FOnReceiveCurConf: TApplication1ReceiveCurConf; FOnStatusChange: TApplication1StatusChange; FIntf: IApplication;{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps: TApplication1Properties; function GetServerProperties: TApplication1Properties;{$ENDIF} function GetDefaultInterface: IApplication; 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: IApplication); procedure Disconnect; override; procedure Connect1(shType: Smallint; const bstrServerIP: WideString; const bstrUser: WideString; const bstrPass: WideString); procedure DisConnect1; function IsConnect: Smallint; function GetSessions: IDispatch; procedure Exit; procedure ShowServer; function GetCurrentAccount: WideString; function GetCurrentHost: WideString; property DefaultInterface: IApplication read GetDefaultInterface; published{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} property Server: TApplication1Properties read GetServerProperties;{$ENDIF} property OnReceiveCurConf: TApplication1ReceiveCurConf read FOnReceiveCurConf write FOnReceiveCurConf; property OnStatusChange: TApplication1StatusChange read FOnStatusChange write FOnStatusChange; end;{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}// *********************************************************************//// OLE Server Properties Proxy Class// Server Object : TApplication1// (This object is used by the IDE's Property Inspector to allow editing// of the properties of this server)// *********************************************************************// TApplication1Properties = class(TPersistent) private FServer: TApplication1; function GetDefaultInterface: IApplication; constructor Create(AServer: TApplication1); protected public property DefaultInterface: IApplication read GetDefaultInterface; published end;{$ENDIF}procedure Register;resourcestring dtlServerPage = 'ActiveX'; dtlOcxPage = 'ActiveX';implementationuses ComObj;class function CoSession.Create: ISession;begin Result := CreateComObject(CLASS_Session) as ISession;end;class function CoSession.CreateRemote(const MachineName: string): ISession;begin Result := CreateRemoteComObject(MachineName, CLASS_Session) as ISession;end;procedure TSession1.InitServerData;const CServerData: TServerData = ( ClassID: '{EC2C9F4C-CFB4-4096-AFC0-1531FC603606}'; IntfIID: '{2F4B1CA9-0DF8-4EC8-92DF-71BACE1DE0AA}'; EventIID: '{4ADE78EF-390A-4FF8-B788-C47E30331B6D}'; LicenseKey: nil; Version: 500);begin ServerData := @CServerData;end;procedure TSession1.Connect;var punk: IUnknown;begin if FIntf = nil then begin punk := GetServer; ConnectEvents(punk); Fintf:= punk as ISession; end;end;procedure TSession1.ConnectTo(svrIntf: ISession);begin Disconnect; FIntf := svrIntf; ConnectEvents(FIntf);end;procedure TSession1.DisConnect;begin if Fintf <> nil then begin DisconnectEvents(FIntf); FIntf := nil; end;end;function TSession1.GetDefaultInterface: ISession;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 TSession1.Create(AOwner: TComponent);begin inherited Create(AOwner);{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps := TSession1Properties.Create(Self);{$ENDIF}end;destructor TSession1.Destroy;begin{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps.Free;{$ENDIF} inherited Destroy;end;{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}function TSession1.GetServerProperties: TSession1Properties;begin Result := FProps;end;{$ENDIF}procedure TSession1.InvokeEvent(DispID: TDispID; var Params: TVariantArray);begin case DispID of -1: Exit; // DISPID_UNKNOWN 1: if Assigned(FOnCPReceive) then FOnCPReceive(Self, Params[0] {Smallint}, Params[1] {Smallint}, Params[2] {Smallint}, Params[3] {Smallint}, Params[4] {Smallint}, Params[5] {const WideString}); end; {case DispID}end;function TSession1.Get_nRow: Smallint;begin Result := DefaultInterface.nRow;end;procedure TSession1.Set_nRow(pVal: Smallint);begin DefaultInterface.Set_nRow(pVal);end;function TSession1.Get_nCol: Smallint;begin Result := DefaultInterface.nCol;end;procedure TSession1.Set_nCol(pVal: Smallint);begin DefaultInterface.Set_nCol(pVal);end;procedure TSession1.InputStr(shH1: Smallint; shH2: Smallint; shSID: Smallint; const bstrCmd: WideString);begin DefaultInterface.InputStr(shH1, shH2, shSID, bstrCmd);end;procedure TSession1.SendStrNow(shH1: Smallint; shH2: Smallint; shSID: Smallint; const bstrCmd: WideString);begin DefaultInterface.SendStrNow(shH1, shH2, shSID, bstrCmd);end;procedure TSession1.SendCmd(shH1: Smallint; shH2: Smallint; shSID: Smallint; X: Smallint; Y: Smallint; shKey: Smallint);begin DefaultInterface.SendCmd(shH1, shH2, shSID, X, Y, shKey);end;procedure TSession1.PrintData(PrinterType: Integer; const PrinterInfo: WideString);begin DefaultInterface.PrintData(PrinterType, PrinterInfo);end;function TSession1.GetLockStatus: Smallint;begin Result := DefaultInterface.GetLockStatus;end;procedure TSession1.GetH1(out H1: Smallint);begin DefaultInterface.GetH1(H1);end;procedure TSession1.GetH2(out H2: Smallint);begin DefaultInterface.GetH2(H2);end;procedure TSession1.GetRID(out RID: Smallint);begin DefaultInterface.GetRID(RID);end;procedure TSession1.GetSID(out SID: Smallint);begin DefaultInterface.GetSID(SID);end;procedure TSession1.FullScreenString(Data: OleVariant);begin DefaultInterface.FullScreenString(Data);end;function TSession1.GetCurrentSessionID: Integer;begin Result := DefaultInterface.GetCurrentSessionID;end;procedure TSession1.Lock;begin DefaultInterface.Lock;end;procedure TSession1.Unlock;begin DefaultInterface.Unlock;end;function TSession1.IsLock: Integer;begin Result := DefaultInterface.IsLock;end;{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}constructor TSession1Properties.Create(AServer: TSession1);begin inherited Create; FServer := AServer;end;function TSession1Properties.GetDefaultInterface: ISession;begin Result := FServer.DefaultInterface;end;function TSession1Properties.Get_nRow: Smallint;begin Result := DefaultInterface.nRow;end;procedure TSession1Properties.Set_nRow(pVal: Smallint);begin DefaultInterface.Set_nRow(pVal);end;function TSession1Properties.Get_nCol: Smallint;begin Result := DefaultInterface.nCol;end;procedure TSession1Properties.Set_nCol(pVal: Smallint);begin DefaultInterface.Set_nCol(pVal);end;{$ENDIF}class function CoSessions.Create: ISessions;begin Result := CreateComObject(CLASS_Sessions) as ISessions;end;class function CoSessions.CreateRemote(const MachineName: string): ISessions;begin Result := CreateRemoteComObject(MachineName, CLASS_Sessions) as ISessions;end;procedure TSessions1.InitServerData;const CServerData: TServerData = ( ClassID: '{FE104F26-4219-4DE0-87B9-8FF12A2A56B1}'; IntfIID: '{74423526-1E08-4A97-BC85-2D5FCC22CDBE}'; EventIID: ''; LicenseKey: nil; Version: 500);begin ServerData := @CServerData;end;procedure TSessions1.Connect;var punk: IUnknown;begin if FIntf = nil then begin punk := GetServer; Fintf:= punk as ISessions; end;end;procedure TSessions1.ConnectTo(svrIntf: ISessions);begin Disconnect; FIntf := svrIntf;end;procedure TSessions1.DisConnect;begin if Fintf <> nil then begin FIntf := nil; end;end;function TSessions1.GetDefaultInterface: ISessions;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 TSessions1.Create(AOwner: TComponent);begin inherited Create(AOwner);{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps := TSessions1Properties.Create(Self);{$ENDIF}end;destructor TSessions1.Destroy;begin{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps.Free;{$ENDIF} inherited Destroy;end;{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}function TSessions1.GetServerProperties: TSessions1Properties;begin Result := FProps;end;{$ENDIF}function TSessions1.Get__NewEnum: IUnknown;begin Result := DefaultInterface._NewEnum;end;function TSessions1.Count: Integer;begin Result := DefaultInterface.Count;end;function TSessions1.Item(index: OleVariant): IDispatch;begin Result := DefaultInterface.Item(index);end;function TSessions1.GetTotalSessionNumber: Integer;begin Result := DefaultInterface.GetTotalSessionNumber;end;function TSessions1.GetActiveSession: Integer;begin Result := DefaultInterface.GetActiveSession;end;{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}constructor TSessions1Properties.Create(AServer: TSessions1);begin inherited Create; FServer := AServer;end;function TSessions1Properties.GetDefaultInterface: ISessions;begin Result := FServer.DefaultInterface;end;function TSessions1Properties.Get__NewEnum: IUnknown;begin Result := DefaultInterface._NewEnum;end;{$ENDIF}class function CoApplication.Create: IApplication;begin Result := CreateComObject(CLASS_Application) as IApplication;end;class function CoApplication.CreateRemote(const MachineName: string): IApplication;begin Result := CreateRemoteComObject(MachineName, CLASS_Application) as IApplication;end;procedure TApplication1.InitServerData;const CServerData: TServerData = ( ClassID: '{C5E9A707-5D62-4C96-A1B0-3DA8B719AA0D}'; IntfIID: '{98AA9DD3-0715-4170-8A96-04F06C8BAD49}'; EventIID: '{3C31BF76-2837-4BFA-A19E-34485A213F29}'; LicenseKey: nil; Version: 500);begin ServerData := @CServerData;end;procedure TApplication1.Connect;var punk: IUnknown;begin if FIntf = nil then begin punk := GetServer; ConnectEvents(punk); Fintf:= punk as IApplication; end;end;procedure TApplication1.ConnectTo(svrIntf: IApplication);begin Disconnect; FIntf := svrIntf; ConnectEvents(FIntf);end;procedure TApplication1.DisConnect;begin if Fintf <> nil then begin DisconnectEvents(FIntf); FIntf := nil; end;end;function TApplication1.GetDefaultInterface: IApplication;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 TApplication1.Create(AOwner: TComponent);begin inherited Create(AOwner);{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps := TApplication1Properties.Create(Self);{$ENDIF}end;destructor TApplication1.Destroy;begin{$IFDEF LIVE_SERVER_AT_DESIGN_TIME} FProps.Free;{$ENDIF} inherited Destroy;end;{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}function TApplication1.GetServerProperties: TApplication1Properties;begin Result := FProps;end;{$ENDIF}procedure TApplication1.InvokeEvent(DispID: TDispID; var Params: TVariantArray);begin case DispID of -1: Exit; // DISPID_UNKNOWN 1: if Assigned(FOnReceiveCurConf) then FOnReceiveCurConf(Self, OleVariant((TVarData(Params[0]).VPointer)^) {var OleVariant}); 2: if Assigned(FOnStatusChange) then FOnStatusChange(Self, Params[0] {Integer}, Params[1] {const WideString}); end; {case DispID}end;procedure TApplication1.Connect1(shType: Smallint; const bstrServerIP: WideString; const bstrUser: WideString; const bstrPass: WideString);begin DefaultInterface.Connect(shType, bstrServerIP, bstrUser, bstrPass);end;procedure TApplication1.DisConnect1;begin DefaultInterface.DisConnect;end;function TApplication1.IsConnect: Smallint;begin Result := DefaultInterface.IsConnect;end;function TApplication1.GetSessions: IDispatch;begin Result := DefaultInterface.GetSessions;end;procedure TApplication1.Exit;begin DefaultInterface.Exit;end;procedure TApplication1.ShowServer;begin DefaultInterface.ShowServer;end;function TApplication1.GetCurrentAccount: WideString;begin Result := DefaultInterface.GetCurrentAccount;end;function TApplication1.GetCurrentHost: WideString;begin Result := DefaultInterface.GetCurrentHost;end;{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}constructor TApplication1Properties.Create(AServer: TApplication1);begin inherited Create; FServer := AServer;end;function TApplication1Properties.GetDefaultInterface: IApplication;begin Result := FServer.DefaultInterface;end;{$ENDIF}procedure Register;begin RegisterComponents(dtlServerPage, [TSession1, TSessions1, TApplication1]);end;end.MyApplication:=CoApplication.Create;MyApplication.Connect(0,'ip','CAAC','CAAC');MyApplication.QueryInterface(IID_ISessions, MySessions);ShowMessage(Format('TotalSession = %d',[MySessions.GetTotalSessionNumber]));无法取到GetTotalSessionNumber.
 
后退
顶部