我的dll文件是这样处理的:
在dll工程里:
library dllname;
uses
  ShareMem,
  SysUtils,
  Classes,
  windows,
  forms,
  ADODB,
//  basequery in 'basequery.pas' {waterquery},
  BaseFm1U in 'BaseFm1U.pas' {BaseFM1};procedure wshowform(AHandle: THandle; Reserve: String; connect:TADOConnection);StdCall;
var
  dllform: Twaterquery;
  apphand: THandle;
begin
  apphand:=Application.Handle;
  Application.Handle := AHandle;
  try
    dllform:= Twaterquery.Create(Application);
    dllform.connected:=@connect;
    dllform.ShowModal;
    Application.Handle := apphand;
  finally
    dllform.Free;
  end;
end;exports
  wshowform;
begin
end.
我的主工程是这样处理的:
procedure process(dllname: string);
var
  LibHandle: THandle;
  showform: Twshowform;
begin
  LibHandle := 0;
  try
    LibHandle := LoadLibrary(LPCTSTR(dllname));
    if LibHandle = 0 then
    begin
       raise EDLLLoadError.Create('此动态链接库不能加载');
       exit;
    end ;
    @showform := GetProcAddress(LibHandle,'wshowform');
    if not (@showform = nil) then
       showform(Application.Handle,'',MainForm.ADOConnection1)
    else
       RaiseLastWin32Error;
  finally
    FreeLibrary(LibHandle); // Unload the DLL.
  end;
end;当释放dll文件时
    FreeLibrary(LibHandle); // Unload the DLL.
总是报cpu内存错不知如何处理????
请大家讨论!!!

解决方案 »

  1.   

    showform: Twshowform;
    这个东西哪来的?
      

  2.   

    这是书上的一个例子呀!把String改成Pchar型
    dllform.connected:=@connect;
    这句是什么意思?Connected是什么东西?为什么要用地址传递?
      

  3.   

    求求你不用ShareMem可不可以?
    把string改为wideString或shortString或PChar等等就不用ShareMem了!
    看到ShareMem怪怪的!
      

  4.   

    能否提供一个完整的例子(但通过exe需要给dll传送一个adoconnect的连接以便adoquery使用)。
      

  5.   

    能否提供一个完整的例子(但通过exe需要给dll传送一个adoconnect的连接以便adoquery使用)。 mail : [email protected]
      

  6.   

    我写过不少Dll,这个问题我也遇到过,后来用ShortString都解决了,
    所以你没必要非用 String,用 ShortString 你的问题不就解决了?