分布式多层数据库系统的应用(一)毕业论(3)
2013-06-02 01:01
导读:或者应用服务器IP地址)和应用服务器的端口号,这些配置信息将用来连接应用服务器。如果连接成功,输入的配置信息将被写入到注册表中,以后程序启
或者应用服务器IP地址)和应用服务器的端口号,这些配置信息将用来连接应用服务器。如果连接成功,输入的配置信息将被写入到注册表中,以后程序启动时,读取注册表配置信息,就可而已连接应用服务器程序了。程序的具体实现部分如程序清单如下所示。
procedure BitBtn1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
procedure WriteToReg(const bappHost,bappIp,aPort:string);
{ Private declarations }
public
{ Public declarations }
end;
var
fm_SerConfig: Tfm_SerConfig; Connected: boolean= false; //代表是否连接成功
implementation
uses netlist, data;
{$R *.dfm}
procedure Tfm_SerConfig.BitBtn1Click(Sender: TObject);
begin
if ((Edt_host.Text='') or (Edt_host.Text=null))
and((Edt_ip.Text='') or (Edt_host.Text=null)) then
begin
application.MessageBox('请输入服务器和IP','输入错误',
mb_iconinformation + mb_defbutton1);
exit;
end;
try
strtoint(edt_Port.text);
except
Application.MessageBox('请输入正确的端口号', '输入错误..', mb_iconinformation + mb_defbutton1);
exit;
end;
statusbar1.Panels[0].Text:='正在连接服务器,pleale wait';
statusbar1.Refresh;
screen.Cursor:=crHourGlass;
fm_data.Socket.Connected:=false;
(科教作文网http://zw.nseAc.com)
fm_data.Socket.Host:=edt_host.Text;
fm_data.Socket.Address:=edt_ip.Text;
fm_data.Socket.Port:=strtoint(edt_port.Text);
try
screen.Cursor:=crdefault;
fm_data.Socket.Connected:=true;
application.MessageBox('连接成功','图书管理系统', mb_iconinformation + mb_defbutton1);
connected:=true;
except
screen.Cursor:=crdefault;
application.MessageBox('连接失败','图书管理系统',mb_iconinformation+mb_defbutton1);
connected:=false;
end;
//连接成功向注册表里写入应用服务器配置信息
WriteToReg(edt_Host.Text, edt_IP.Text, edt_Port.Text);
close;
end;
//利用可视化窗体来选择计算机
procedure Tfm_SerConfig.Button1Click(Sender: TObject);
begin
edt_ip.Clear;
edt_host.Text:= NetExecute(TFm_NetList);
end;
//把信息写入注册表
procedure Tfm_SerConfig.WriteToReg(const bappHost,bappIp,aPort:string);
var
reg:Tregistry;
begin
reg:=Tregistry.Create;
reg.RootKey:=HKEY_LOCAL_MACHINE;
if not reg.OpenKey('\Software\pz',false) then //如果可以创建目录
begin
reg.CreateKey('\Software\pz');
reg.OpenKey('\Software\pz',false);
end;
reg.WriteString('host',bapph