{ 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. }解决方法1: project2(工程文件,不是单元文件)的uses中第一项(新增加)为ShareMem project1的uses中第一项(新增加)为ShareMem解决方法2:使用,不用string传递参数 function getMyInfo(myInt1,myInt2:Integer):pchar;StdCall; begin Result:=pchar(IntToStr(myInt1+myInt2)); end; --------------------------------------------------------------------- function getMyInfo(myInt1,myInt2:Integer):pchar;StdCall external 'project1.dll'; procedure TForm1.BitBtn1Click(Sender: TObject); begin MessageDlg('Result is:'+string(getMyInfo(2,3)), mtInformation,[mbOk], 0); end;
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. }解决方法1:
project2(工程文件,不是单元文件)的uses中第一项(新增加)为ShareMem
project1的uses中第一项(新增加)为ShareMem解决方法2:使用,不用string传递参数
function getMyInfo(myInt1,myInt2:Integer):pchar;StdCall;
begin
Result:=pchar(IntToStr(myInt1+myInt2));
end;
---------------------------------------------------------------------
function getMyInfo(myInt1,myInt2:Integer):pchar;StdCall external 'project1.dll';
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
MessageDlg('Result is:'+string(getMyInfo(2,3)), mtInformation,[mbOk], 0);
end;
同学给我们机会。:)
如果用string可以uses那个me什么单元,然后实时包
帮忙多谢