靴
靴子
Unregistered / Unconfirmed
GUEST, unregistred user!
我在做三层数据库时:
1、如果远程模块中的代码是这样的
implementation
uses unit1;
{$R *.DFM}
class procedure Tzhao.UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
begin
if Register then
begin
inherited UpdateRegistry(Register, ClassID, ProgID);
EnableSocketTransport(ClassID);
EnableWebTransport(ClassID);
end else
begin
DisableSocketTransport(ClassID);
DisableWebTransport(ClassID);
inherited UpdateRegistry(Register, ClassID, ProgID);
end;
end;
procedure Tzhao.RemoteDataModuleCreate(Sender: TObject);
begin
form1.UpdateClientCount(1);//是在form1中写的一个过程
end;
initialization
TComponentFactory.Create(ComServer, Tzhao,
Class_zhao, ciMultiInstance, tmApartment);
end.
则当启动客户端时,就是启动不起来;
其中UpdateClientCount是这样的
FClientCount在
private
FClientCount: Integer;
声明的
procedure TForm1.UpdateClientCount(Incr: Integer);
begin
FClientCount := FClientCount + Incr;
Label1.Caption := IntToStr(FClientCount);
end;
2、如果把远程代码写成
implementation
uses unit1;
{$R *.DFM}
class procedure Tzhao.UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
begin
if Register then
begin
inherited UpdateRegistry(Register, ClassID, ProgID);
EnableSocketTransport(ClassID);
EnableWebTransport(ClassID);
end else
begin
DisableSocketTransport(ClassID);
DisableWebTransport(ClassID);
inherited UpdateRegistry(Register, ClassID, ProgID);
end;
end;
procedure Tzhao.RemoteDataModuleCreate(Sender: TObject);
begin
form1.UpdateClientCount(1);
end;
initialization
TComponentFactory.Create(ComServer, Tzhao,
Class_zhao, ciMultiInstance);
end.
这个的就没问题
就是把tmApartment从initialization
TComponentFactory.Create(ComServer, Tzhao,
Class_zhao, ciMultiInstance,tmApartment);去掉就正常了啊。
请问大侠这是什么原因呢?
3。如果我用1的方法?难道UpdateClientCount不能写在 远程模块中的oncreat中吗?
1、如果远程模块中的代码是这样的
implementation
uses unit1;
{$R *.DFM}
class procedure Tzhao.UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
begin
if Register then
begin
inherited UpdateRegistry(Register, ClassID, ProgID);
EnableSocketTransport(ClassID);
EnableWebTransport(ClassID);
end else
begin
DisableSocketTransport(ClassID);
DisableWebTransport(ClassID);
inherited UpdateRegistry(Register, ClassID, ProgID);
end;
end;
procedure Tzhao.RemoteDataModuleCreate(Sender: TObject);
begin
form1.UpdateClientCount(1);//是在form1中写的一个过程
end;
initialization
TComponentFactory.Create(ComServer, Tzhao,
Class_zhao, ciMultiInstance, tmApartment);
end.
则当启动客户端时,就是启动不起来;
其中UpdateClientCount是这样的
FClientCount在
private
FClientCount: Integer;
声明的
procedure TForm1.UpdateClientCount(Incr: Integer);
begin
FClientCount := FClientCount + Incr;
Label1.Caption := IntToStr(FClientCount);
end;
2、如果把远程代码写成
implementation
uses unit1;
{$R *.DFM}
class procedure Tzhao.UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
begin
if Register then
begin
inherited UpdateRegistry(Register, ClassID, ProgID);
EnableSocketTransport(ClassID);
EnableWebTransport(ClassID);
end else
begin
DisableSocketTransport(ClassID);
DisableWebTransport(ClassID);
inherited UpdateRegistry(Register, ClassID, ProgID);
end;
end;
procedure Tzhao.RemoteDataModuleCreate(Sender: TObject);
begin
form1.UpdateClientCount(1);
end;
initialization
TComponentFactory.Create(ComServer, Tzhao,
Class_zhao, ciMultiInstance);
end.
这个的就没问题
就是把tmApartment从initialization
TComponentFactory.Create(ComServer, Tzhao,
Class_zhao, ciMultiInstance,tmApartment);去掉就正常了啊。
请问大侠这是什么原因呢?
3。如果我用1的方法?难道UpdateClientCount不能写在 远程模块中的oncreat中吗?