用project1.exe去调用里面的功能,但在98下提示非法操作。在win2000下提示:“在c:\winnt\system32\;......”找不到a.dll。如何解决? 
 
  dll文件和调用程序在同一个目录里。
function add_one(num:integer):integer ;stdcall;external 'D:\Borland\Delphi5\Projects\dll\Pmaxdll'
     name 'add_one';运行后出现无效的页面错误,
--------------
program Project1;uses
  Forms,
  addone in 'addone.pas' {Form1};{$R *.RES}begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
----
unit addone;interfaceuses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
  function add_one(num:integer):integer ;stdcall;external 'D:\Borland\Delphi5\Projects\dll\Pmaxdll'
     name 'add_one';
  function dec_one(num:integer):integer ;stdcall;external 'D:\Borland\Delphi5\Projects\dll\Pmaxdll'
     name 'dec_one';
implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
  edit1.Text:=inttostr(add_one(strtoint(edit1.text)));
end;procedure TForm1.Button2Click(Sender: TObject);
begin
  edit1.Text:=inttostr(dec_one(strtoint(edit1.text)));
end;end.
---
library Pmaxdll;
uses
  SysUtils,
  Classes;
function add_one(num:integer):integer ;
  begin
    result:=num+1;
  end;
function dec_one(num:integer):integer ;
begin
  result:=num-1;
end;
exports add_one,dec_one;
{$R *.RES}
begin
end.
 
 

解决方案 »

  1.   

    function add_one(num:integer):integer ;stdcall;external 'D:\Borland\Delphi5\Projects\dll\Pmaxdll'
         name 'add_one';
      

  2.   

    你看吧DLL的改成
    function add_one(num:integer):integer ; stdcall;
      begin
        result:=num+1;
      end;
    function dec_one(num:integer):integer ; stdcall;
    begin
      result:=num-1;
    end;
    行不行?
      

  3.   

    强调:
    不用放到系统目录中
    放到你的软件目录下即可调用:
    用api函数:GetCurrentDir
    然后再加上你的库相对于.exe的相对路径即可
      

  4.   

    现在可以运行了,但是退出时run time error at %$#%^$$^$
    是不是在退出时应该有一些资源释放的动作