dll问题,调用dll中的窗体

zxtyhy 2006-12-14 08:59:17
dll中的接口函数

function Init(hWndParent: HWND; gid: Int64; pszUserPath: LPCTSTR): HWND; stdcall;
begin
CoInitialize(nil);
FrmPCDll := TFrmPCDll.CreateParented(hWndParent);
FrmPCDll.Visible := True;
Result := FrmPCDll.Handle;
end;


调用时
begin
Init(Handle, 0, 'aaa');
end;

在关闭主程序时总是出错,提示Runtime error 216 at 004A661D

应该如何处理?
...全文
187 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Louis_WH 2006-12-18
  • 打赏
  • 举报
回复
不明白,就是要调用DLL中的窗口吧?写个显示窗口的函数再exports出来不就完了?干嘛还写
初始和结束函数?
zuoansuifeng 2006-12-15
  • 打赏
  • 举报
回复
Init name 'Init',
Quit name 'Quit';

输出的函数为什么要这么写
直接写
Init
Quit
zxtyhy 2006-12-14
  • 打赏
  • 举报
回复
DLL完整代码:
library Project1;

uses
Windows,
ActiveX,
Forms,
UnitPCDll in 'UnitPCDll.pas' {FrmPCDll},
Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

function Init(hWndParent: HWND; gid: Int64; pszUserPath: LPCTSTR): HWND; stdcall;
begin
CoInitialize(nil);

Application.Handle := hWndParent;
FrmPCDll := TFrmPCDll.Create(Application);
FrmPCDll.ParentWindow := hWndParent;
FrmPCDll.Visible := True;
Result := FrmPCDll.Handle;
end;

procedure Quit; stdcall;
begin
if Assigned(FrmPCDll) then
begin
FrmPCDll.Free;
FrmPCDll := nil;
end;

CoUninitialize;
end;


exports
Init name 'Init',
Quit name 'Quit';

begin

end.

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧