serverunit2.~pas

来自「Delphi6分布式开发例程 )」· ~PAS 代码 · 共 59 行

~PAS
59
字号
unit ServerUnit2;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, ComObj, StdVcl,
  CorbaObj, Project1_TLB;

type
  //声明一个类 CorbaSample
  TCorbaSample = class(TCorbaImplementation, ICorbaSample)
  private
    { Private declarations }
  
  protected
    //CorbaSample类有三个方法
    function Add(x, y: Integer): Integer; safecall;
    function Multiply(x, y: Integer): Integer; safecall;
    function Subtract(x, y: Integer): Integer; safecall;
    function Divide(x, y: Integer): Single; safecall;public
    { Public declarations }
  end;

implementation

uses CorbInit, ServerUnit1;

function TCorbaSample.Add(x, y: Integer): Integer;
begin
  Result := x + y;
  //在服务器上显示Add调用消息
  Form1.Memo1.Lines.Append('客户程序调用了Add方法!');
end;

function TCorbaSample.Multiply(x, y: Integer): Integer;
begin
  Result := x * y;
  //在服务器上显示Multiply调用消息
  Form1.Memo1.Lines.Append('客户程序调用了Multiply方法!');
end;

function TCorbaSample.Subtract(x, y: Integer): Integer;
begin
  Result := x - y;
  //在服务器上显示Subtract调用消息
  Form1.Memo1.Lines.Append('客户程序调用了Subtract方法!');
end;

function TCorbaSample.Divide(x, y: Integer): Single;
begin
  Result := x / y;
  //在服务器上显示Divide调用信息
  Form1.Memo1.Lines.Append('客户程序调用了Divide方法!');
end;

initialization
  TCorbaObjectFactory.Create('CorbaSampleFactory', 'CorbaSample', 'IDL:Project1/CorbaSampleFactory:1.0', ICorbaSample,
    TCorbaSample, iMultiInstance, tmSingleThread);
end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?