我是这样写的
library Project1;
uses
  Windows,
  Messages,
  SysUtils,
  Classes,
  Forms;        procedure ShowForm_Center(H:THandle;Dest_Form:TForm);StdCall;
        Begin
           Application.Handle:=H;
           Dest_Form.Top:=(Screen.Height-Dest_Form.Height) div 2;
           Dest_Form.Left:=(Screen.Width-Dest_Form.Width) div 2;
        End;
        exports ShowForm_Center;但是在窗口的onshow事件中调用时ShowForm_Center_A(Application.Handle,Form1);
却报以下错误:
project project1.exe raised exception class EAccessViolation with message 'Access violation at address 0024EA69 in module 'Project1.dll'.Read of address B88366CF'.Process stopped.Use Step or Run to continue.

解决方案 »

  1.   

    静态调用了dll
    procedure ShowForm_Center_A(Handle:THandle;Dest_Form:TForm);far;external 'Project1.dll' name 'ShowForm_Center_';
      

  2.   

    如果你要写成标准dll就不要传递TForm这种类参数,如果要就编写成程序包即bpl文件
    procedure ShowForm_Center(H:THandle;Dest_Form:TForm);StdCall;
      

  3.   

    在interface里生命
    procedure ShowForm_Center_A(Handle:THandle;Dest_Form:TForm);external;然后在impelmention里实现
    procedure ShowForm_Center_A(Handle:THandle;Dest_Form:TForm);external 'Project1.dll' name 'ShowForm_Center';应该没有什么问题吧?
    不过我觉得你那好象麻烦了吧?
    直接调用form.positon属性不就行了??
      

  4.   

    但是我在button的onclick事件中写ShowForm_Center_A(Application.Handle,Form1);
    没有报错,窗口并未居中
      

  5.   

    修改声明如下试试:
    procedure ShowForm_Center_A(Handle:THandle;Dest_Form:TForm);stdcall;external 'Project1.dll' name 'ShowForm_Center_';
      

  6.   

    非常感谢大家,,使用了aiirii(ari) 的方法调试没有问题,散分!