//主程序调用DLL
procedure TfrmMain.ProjectSumExecute(Sender: TObject);
var
  DllHandle: Thandle;
  DllExecute: Function(AHandle: THandle; ProjectID,UserID: PChar; Level: Integer;DataSource: TDataSource):DWord;stdcall;
begin
  DllHandle := LoadLibrary(ProjectSumDllName);
  if DllHandle <> 0 then
  begin
    @DllExecute := GetProcAddress(DllHandle,ProjectSumFunName);
    if @DllExecute <> nil then
    begin
      DllExecute(frmMain.Handle,PChar(PROJECT_ID),PChar(FUserID),FLevel,data.daProjectSum);
      @DllExecute := nil;
      FreeLibrary(DllHandle);
    end;
  end;
end;
//DLL导出函数
function ProjectSumExecute(AHandle: THandle;ProjectID,UserID: PChar; Level: Integer;DataSource: TDataSource):DWord;
begin
  Application.Handle := AHandle;
  with TFrmMain.Create(Application) do
  begin
    MyDataSource := DataSource;
    try
      ShowModal;
    finally
      free;
    end;
  end;
  result := 0;
end;
//DLL中主窗体
procedure TFrmMain.FormShow(Sender: TObject);
begin
  try
    dxDBGrid1.DataSource := MyDataSource;
    DBNavigator1.DataSource := MyDataSource;
    dxDBGrid1.DataSource.DataSet.Open;
    dxDBGrid1.DataSource.DataSet.Edit;
  except
  end;
end;
注明:我在主程序中和DLL中均使用了Dev Express 中的DxDBGrid控件。
出现问题:经常出现莫名其妙的问题,我请教了以为高手,他说我的DLL地址冲突所致,有时程序甚至会自动关闭。请问是什么原因?