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应该如何处理?

解决方案 »

  1.   

    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';beginend.
      

  2.   

    Init name 'Init',
      Quit name 'Quit';输出的函数为什么要这么写 
     直接写
     Init
     Quit
      

  3.   

    不明白,就是要调用DLL中的窗口吧?写个显示窗口的函数再exports出来不就完了?干嘛还写
    初始和结束函数?