//////////////////////////////////////   dll的代码
library strop;uses
  SysUtils,
  Classes;{$R *.res}
{返回字符在字符串中的位置}
function instr(sourcestr:pchar;ch:char):integer;stdcall;export;
var
   len,i: integer;
begin
  len := strlen(sourcestr);
  for i := 0 to len-1 do
    if sourcestr[i] = ch then
      begin
      result := i;
      exit;
      end;
    result := -1;
end; exports
  instr index 1 name 'myinstr' resident;begin
end.
//****************************************************************************
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;function instr(sourcestr:pchar;ch:char):integer;stdcall;external 'myinstr';
var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
  sourcestr,ch :string;
begin
   sourcestr := edit1.Text;
   ch := edit2.Text;
   button1.Caption := intTostr(instr(pchar(sourcestr),char(ch[1])));
end;end.

解决方案 »

  1.   

    DLL与EXE在同一个目录下就ok的http://lysoft.7u7.net
      

  2.   

    button1.Caption := intTostr(myinstr(pchar(sourcestr),char(ch[1])));
                                 **
    看看如何?
      

  3.   

    这点常识我是有滴,DLL与EXE在同一个目录下,但不ok。
      

  4.   

    button1.Caption := intTostr(myinstr(pchar(sourcestr),char(ch[1])));[Error] Unit1.pas(39): Undeclared identifier: 'myinstr'
      

  5.   

    function instr(sourcestr:pchar;ch:char):integer;stdcall;external 'myinstr.dll';
      

  6.   

    哦,清楚了,问题还是在访问文件上,我把dll文件的名称改为myinstr.dll就不出现该问题了。但出现的新问题:‘无法定位程序输入点instr于动态链接库myinstr.dll上。
    help!!!!!!!!!
      

  7.   

    hoho~~~
    谢谢各位,成功了。
    等着我结贴给分