📄 serverunit2.~pas
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -