报错内容:
  说"Ox...."指令引用的"Ox....."内存,内存不能为Read代码:
Procedure AutoIDConnection(x:TADOConnection;EnterID:String);
begin
   EnterpriseID:=EnterID;
   Connection:=x;
   ADOQuery_Comm:=TADOQuery.Create(nil);
   ADOQuery_Comm.Connection:=Connection;
   ADOQuery_Comm.Close;
end;
参数类型改成这样就没事
Procedure AutoIDConnection(x:TADOConnection;EnterID:PChar);
begin
   EnterpriseID:=EnterID;
   Connection:=x;
   ADOQuery_Comm:=TADOQuery.Create(nil);
   ADOQuery_Comm.Connection:=Connection;
   ADOQuery_Comm.Close;
end;

解决方案 »

  1.   

    函数的参数和返回值不要用String类型,用Pchar较好,其它语言比较通用
    如要用string类型,必须再单元中uses sharemem,动态链接库和应用程序都加上
    为了能让其他的程序能够调用dll中的过程,要输出的过程最好采用stdcall调用约定。而且被其他语言调用的时候,过程参数类型和返回类型必须是其他语言中的合法数据类型
      

  2.   

    { Important note about DLL memory management: ShareMem must be the
      first unit in your library's USES clause AND your project's (select
      Project-View Source) USES clause if your DLL exports any procedures or
      functions that pass strings as parameters or function results. This
      applies to all strings passed to and from your DLL--even those that
      are nested in records and classes. ShareMem is the interface unit to
      the BORLNDMM.DLL shared memory manager, which must be deployed along
      with your DLL. To avoid using BORLNDMM.DLL, pass string information
      using PChar or ShortString parameters. }
      

  3.   

    如果要返回String 类型要在Dll里面首先引用
    uses
      ShareMem,
    在工程里面也要首先引用
    uses
      ShareMem,
      

  4.   

    顺便问一句:
      用PChar类型参数,好象borland公司说PChar类型不安全,是这样吗?
      

  5.   

    好像不是这样子的吧PChar 类型的是有结尾符号的,读取处理起来应该更安全(在作为动态库参数)
    String类型的就没有结尾符号,所以不可以作动态库参数传递,是不安全的
      

  6.   

    我没遇到过这个问题,在处理Dll接口的问题上,要保持用指针的习惯,不是所有语言都认识你的接口的,明白吗?
      

  7.   

    用PChar,我们在做的系统有十几个DLL,字符型都是用PChar,每什么问题的!
      

  8.   

    用PChar,我们在做的系统有十几个DLL,字符型都是用PChar,没什么问题的!