//在ro的服务端写入如下代码,从ini配置文件读取数据库连接,设置端口号
procedure TServerDataModule.DataModuleCreate(Sender: TObject);
var aExePath:String;
aIni:TInifile;
aConnectionString:String;
aPort:integer;
begin
aExePath:=ExtractFilePath(paramstr(0));
try
aIni:=TIniFile.Create(aExePath+'Config.ini');
aConnectionString:=aIni.ReadString('Server','ConnectionString','');
aPort:=aIni.ReadInteger('Server','Port',8099);
ConnectionManager.Connections[0].ConnectionString :=aConnectionString;
Server.Port :=aPort;
Server.Active :=true;
finally
aIni.Free;
end;
end;
//设置客户端的url地址
function GetTargetURL: String;
var aExePath:String;
aIni:TInifile;
aTargetURL:String;
begin
aExePath:=ExtractFilePath(paramstr(0));
try
aIni:=TIniFile.Create(aExePath+'Config.ini');
aTargetURL:=aIni.ReadString('Server','TargetURL','');
finally
aIni.Free;
Result:=aTargetURL ;
end;
end;
Channel.TargetURL :=GetTargetURL;