现场给100分,我在主窗体调用一个DLL中的窗体,碰到一个难题.
我在主程序中,加载一个DLL,DLL的每个窗体都事先注册过窗体类.代码如下
加载代码如下:
initialization
RegisterClassE()
procedure TManagerForm.RegisterClassE(AClass: TPersistentClass);
var
Index:Integer;
begin
Index:=FindClassE(AClass);
if Index<0 then
begin
FClassList.Add(AClass);
try
RegisterClass(AClass);
ShowMessage('成功注册');
except
ShowMessage('没成功');
end;
end;
end;
程序提示注册成功....
主程序调用代码如下
procedure TLoadModule.LoadAllModule;
var
i,aHandle:Integer;
AModule:PModuleRecord;
AModuleName:string;
Initproc:TInitModule;
begin
ReadIniFile;
for i:=0 to ModuleList.Count-1 do
begin
AModuleName:=ExtractFilePath(ParamStr(0))+'Dll\'+ModuleList.ValueFromIndex[i];
if not FindModule(AModuleName) then
begin
New(AModule);
AHandle := LoadLibrary(PChar(AModuleName));
AModule.ModuleName:=AModuleName;
if AHandle=0 then
begin
ShowMessage('装载DLL文件:'+AModuleName+'出错!');
Continue;
end;
AModule.Handle:=AHandle;
@Initproc := GetProcAddress(AHandle, PChar(InitProcedure));
if (@Initproc<>NIL) then
Initproc;
LoadList.Add(AModule);
end;
end;
end;
执行时,我在主程序却提示找不到这个我要注册的窗体...不知道为什么.