在Remote data module 中能使用Constructor(构造器)吗? ( 积分: 100 )

R

riccdw

Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:
unit RDM;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
DBClient, GP50Server_TLB, StdVcl, DBTables, Provider, DB;
type
TGP50RDM = class(TRemoteDataModule, IGP50RDM)
...
private
{ Private declarations }
protected
class procedure UpdateRegistry(Register: Boolean;
const ClassID, ProgID: string);
override;
public
{ Public declarations }
//第一种:按照系统的原型或不带参数:
//编译时[Error] RDM.pas(205): Declaration of 'Create' differs from previous declaration //好像说的意思是:"说明与先前的说明不同"
Constructor Create(ComServer:TComServerObject;CompentClass:TComponentClass;Const ClassID:TGUID;Instancing:TClassInstancing;ThreadingModel:TThreadingModel);
override;
Constructor Create();override;
//第二种:
//编译时:[Error] Main.pas(16): Unsatisfied forward or external declaration: 'TForm1.create'//好像说的意思是:"不满足的向前或外部说明"
constructor create(TOwner:TComponent);override;
end;

...
implementation

[red]//---个人感觉,构造函数,声明与实现没有一一对应的情况下,编译就会出来上面的提示.
constructor TGP50RDM.create(TOwner:TComponent);
begin
//---实现自定义--
....
end;
[/red]
{$R *.DFM}
....
initialization
//--定义的原型:--加入Remote date module时,系统自动创建的,只不过我把它贴出来
{
TComponentFactory.Create:proceduce
(ComServer:TComServerObject;CompentClass:TComponentClass;
Const ClassID:TGUID;Instancing:TClassInstancing;ThreadingModel:TThreadingModel=tmSingle);
}
//--加入Remote date module时,系统自动创建的
TComponentFactory.Create(ComServer, TGP50RDM,
Class_GP50RDM, ciMultiInstance, tmApartment);
end.

说明:我想要的结果是调用Remote data module模块时.通过构造器来实现读取ini配置文件.ini文件中存有数据库登陆名和密码.
不知道这样子实现有没有问题,或者是有更好的方法,请各位指点指点...
 
重写Create函数就行了
 
这个意思.我明白了.
主要的问题是我连在public声明一下.编译也不能通过啦~
 
??不会的啊,其实他也有OnCreate和OnDestroy事件可以用
 
这个建议不错.本人也想到了.可是有一个问题
在获取文件路径时:ExtractFilePath(Application.ExeName)不认识Application.
而且我也引用了
 
ExtractFilePath(ParamStr(0))
 
建议你ini配置文件放一个固定目录,或者放一个注册表可以查到的目录,或者放在System32目录下,这样便于你的程序查找,毕竟启动这个Remote Data Module的进程可能在任何地方。
 
TO zqw0117
非常感谢你的建议,以及这个ExtractFilePath(ParamStr(0)) 给我解决了一个大问题.
我的ini配置文件放一个固定目录,而且是与中间件放在一起的
 
使用
var
FileName: array[0..MAX_PATH] of Char;
GetModuleFileName(HInstance, FileName, MAX_PATH);
ExtractFilePath(FileName);
这个(dll的也搞得到)
 
再次谢谢两位...
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
464
import
I
顶部