下面是程序的代码:
implementation
function mymax(x,y:integer):string;stdcall;
external 'DLL1.dll';{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(mymax(strtoint(edit1.Text),strtoint(edit2.Text)));
end;
下面是DLL的代码:
library DLL1;uses
SysUtils,
Classes;function mymax(x,y:integer):string;stdcall;
begin
if (x <> 0) and (y <> 0) then
if x > y then
result:=inttostr(x)
else if x < y then
result:=inttostr(y)
else
result:='两个数一样都是:'+inttostr(x); end;{$R *.res}
exports
mymax;begin
end.
程序运行后,点击按钮1之后就出现一个正确提示的对话框,然后在对话框点确定之后就出现这样的错误提示:Invalid pointer operation请问一下,问题出在哪
implementation
function mymax(x,y:integer):string;stdcall;
external 'DLL1.dll';{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(mymax(strtoint(edit1.Text),strtoint(edit2.Text)));
end;
下面是DLL的代码:
library DLL1;uses
SysUtils,
Classes;function mymax(x,y:integer):string;stdcall;
begin
if (x <> 0) and (y <> 0) then
if x > y then
result:=inttostr(x)
else if x < y then
result:=inttostr(y)
else
result:='两个数一样都是:'+inttostr(x); end;{$R *.res}
exports
mymax;begin
end.
程序运行后,点击按钮1之后就出现一个正确提示的对话框,然后在对话框点确定之后就出现这样的错误提示:Invalid pointer operation请问一下,问题出在哪
解决方案 »
- TObjectList 有20万条;如何快速 填充到 Stringlist 上面
- 毛遂自荐寻delphi兼职
- delphi如何做SQLserver2000数据库还原?
- 新!!新!!dbgrid新问题,联想功能。高手请进。急。
- 初学delphi 发布问题请大家帮忙!!!!
- 關于Current Language的問題
- 一个简单的问题
- 如何捕捉Eoleexecption类异常,并显示异常的错误号?
- mid中,怎样使几个窗口都显出来??怎样将他们在不同的显示器上都可以成比例的显示?
- 在Delphi5中如何实现把excel文件中的内容导入到文本文件中,100分
- AlphaControls里的 两个参数在何处?
- 求助,内存查找软件Cheat Engine源代码
{ 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. }在你的DLL文件中加上 ShareMem,而且必须在最前边library DLL1;uses
ShareMem,
SysUtils,
Classes;在你的程序Unit里也要加上这个