J
janestory
Unregistered / Unconfirmed
GUEST, unregistred user!
本人刚开始接触Dll的创建及使用,按着例子建立了如下Dll,可以编译通过,但运行时提示“无法定位程序输入点Instr于动态链接库Example.dll上”,不知何解,请各位指教。
example.dll的源文件如下:
var
len,i:Integer;
begin
Len := strlen(SourceStr);
for i:=0 to Len-1 do
if SourceStr = ch then
begin
Result := i;
Exit;
End;
Result:=-1;
End;
exports
Instr ;
begin
end.
调用的代码如下:
unit test;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
function Instr(SourceStr : PChar;Check : Char): Integer
external 'example.dll';
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(inttostr(Instr('abcd','c')));
end;
end.
example.dll的源文件如下:
var
len,i:Integer;
begin
Len := strlen(SourceStr);
for i:=0 to Len-1 do
if SourceStr = ch then
begin
Result := i;
Exit;
End;
Result:=-1;
End;
exports
Instr ;
begin
end.
调用的代码如下:
unit test;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
function Instr(SourceStr : PChar;Check : Char): Integer
external 'example.dll';
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(inttostr(Instr('abcd','c')));
end;
end.