1
1_1_1_1
Unregistered / Unconfirmed
GUEST, unregistred user!
DLL问题:
DLL代码:
Project1.dpr文件内容:
library Project1;
{ 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. }
uses
SysUtils,
Classes,
Unit1 in 'Unit1.pas';
{$R *.RES}
exports
Mess;
begin
end.
Unit1.pas单元内容:
unit Unit1;
interface
function Mess(value: string): string;
stdcall;
implementation
function Mess(value: string): string;
begin
Result:=value;
end;
end.
调用DLL代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function Mess(value: string): string;
stdcall;
external 'Project1.dll';
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(Mess('中国'));
end;
end.
问题:
单击按钮后显示消息框点击确定后就显示错误:“Invalid pointer operation.”
请问是什么原因?谁能告诉我呢?
先谢了
tang_8717@163.com
DLL代码:
Project1.dpr文件内容:
library Project1;
{ 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. }
uses
SysUtils,
Classes,
Unit1 in 'Unit1.pas';
{$R *.RES}
exports
Mess;
begin
end.
Unit1.pas单元内容:
unit Unit1;
interface
function Mess(value: string): string;
stdcall;
implementation
function Mess(value: string): string;
begin
Result:=value;
end;
end.
调用DLL代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function Mess(value: string): string;
stdcall;
external 'Project1.dll';
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(Mess('中国'));
end;
end.
问题:
单击按钮后显示消息框点击确定后就显示错误:“Invalid pointer operation.”
请问是什么原因?谁能告诉我呢?
先谢了
tang_8717@163.com