DLL中能否使用RegisterClass?
时间:2011-11-29
来源:互联网
请教各位高人,能否住DLL中使用RegisterClass注册类,并住调用程序软件代码中使用GetClass将其取出?为什么俺每次都非到?谢谢!
//MYLIB.DLL:
initialization
RegisterClass(TMyClass);
finalization
UnregisterClass(TMyClass);
end.
//Application:
...
LoadLibrary('MYLIB.DLL');
if GetClass('TMyClass') = nil
then ShowMessage('Class not found');
怎么都找不到?要怎么弄呢?
作者: case5166 发布时间: 2011-11-29
作者: funxu 发布时间: 2011-11-29
exe中的RegGroups中含有你的相关类的注册信息
------------------------------------------------
额,,我在网上查了下是这样说的,但是我现在有一套源码却是采用DLL来做的,在library界面中也没有看见有有导出方法来SHOW窗体,
其下有注册类
initialization
RegisterClassE(TCallProcTestfrm);
finalization
UnRegisterClassE(TCallProcTestfrm);
但源代码不完整,所以不怎么明白是怎么实现的
作者: case5166 发布时间: 2011-11-29
If a class is registered in a dynamic-link library (DLL) with the RegisterClass() function and an application uses this class when creating a window or a dialog box, then the CreateDialog() or CreateWindow() call in the application will fail. The debug version of Windows will produce a Fatal Exit code 0x8800 with the following message:
作者: funxu 发布时间: 2011-11-29
作者: funxu 发布时间: 2011-11-29
To register a window class in a DLL and subsequently create a window (or create a dialog box) of that class in any application that links into this DLL, the window class must be registered with the CS_GLOBALCLASS class style. This style specifies that the window class is an application global class, and will allow this class to be accessed globally by all applications. The CS_GLOBALCLASS class style is documented in the Windows version 3.1 SDK "Programmer's Reference, Volume 1: Overview," manual on page 19 under the Class Styles section.
不过暂时只能帮这么多了,dll注册类用的不多
作者: funxu 发布时间: 2011-11-29
难道二者结合后可以从BPL中获得---?
------------BPL中一窗体管理单元
interface
uses Classes,SysUtils;
type
TManagerForm=class(TObject)
private
FClassList:TList;
function GetClass(Index: Integer): TPersistentClass;
function GetCount: Integer;
public
constructor Create;
destructor Destroy;override;
function FindClassE(AClass:TPersistentClass):Integer;
procedure RegisterClassE(AClass:TPersistentClass);
procedure UnRegisterClassE(AClass:TPersistentClass);
property Items[Index:Integer]:TPersistentClass read GetClass;
property Count:Integer read GetCount;
end;
procedure RegisterClassE(AClass:TPersistentClass); //注册窗体类函数
procedure UnRegisterClassE(AClass:TPersistentClass); //反注册窗体类函数
var
GoManagerForm:TManagerForm;
implementation
procedure RegisterClassE(AClass:TPersistentClass);
begin
GoManagerForm.RegisterClassE(AClass);
end;
procedure UnRegisterClassE(AClass:TPersistentClass);
begin
GoManagerForm.UnRegisterClassE(AClass);
end;
{ TManagerForm }
constructor TManagerForm.Create;
begin
FClassList:=TList.Create;
end;
destructor TManagerForm.Destroy;
begin
FClassList.Free;
inherited;
end;
function TManagerForm.FindClassE(AClass: TPersistentClass): Integer;
var
i:Integer;
loClass:TPersistentClass;
begin
Result:=-1;
for i:=0 to Count-1 do
begin
loClass:=TPersistentClass(FClassList[i]);
if AClass=loClass then
begin
Result:=i;
Exit;
end;
end;
end;
function TManagerForm.GetClass(Index: Integer): TPersistentClass;
begin
if (Index>-1) and (Index<Count) then
Result:=TPersistentClass(FClassList[Index])
else
Result:=nil;
end;
function TManagerForm.GetCount: Integer;
begin
Result:=FClassList.Count;
end;
procedure TManagerForm.RegisterClassE(AClass: TPersistentClass);
var
Index:Integer;
begin
Index:=FindClassE(AClass);
if Index<0 then
begin
FClassList.Add(AClass);
try
RegisterClass(AClass);
except
end;
end;
end;
procedure TManagerForm.UnRegisterClassE(AClass: TPersistentClass);
var
Index:Integer;
begin
Index:=FindClassE(AClass);
if Index>=0 then
begin
FClassList.Delete(Index);
try
UnRegisterClass(AClass);
except
end;
end;
end;
initialization
GoManagerForm:=TManagerForm.Create;
finalization
GoManagerForm.Free;
end.
作者: case5166 发布时间: 2011-11-29
找到说明了
To register a window class in a DLL and subsequently create a window (or create a dialog box) of that class in any application that links into this DLL, the window class must be registered with……
没怎么看明白其意思---这方面其实自己也不怎么用得上,本想学习下其思路
似乎这个对自己来说有点难了

作者: case5166 发布时间: 2011-11-29
作者: funxu 发布时间: 2011-11-29
除非你的DLL和EXE都是带运行时包运行的.Classes才会都用运行时包中的
作者: wr960204 发布时间: 2011-11-29
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28