我用Delphi6写了一个很简单的DLL,结果VB6调用的时候报错“找不到此函数的入口”。可以肯定的是VB6调用DLL函数的写法是正确的,就是不能判断Delphi6写的这个例子是否有问题,请不吝赐教。例子源码如下:library Simple;{ 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;{$R *.res}function add1(Ai: Integer): Integer; stdcall;
begin
  Ai:= Ai + 1;
end;
exports add1 index 1;begin
end.

解决方案 »

  1.   

    exports add1 index 1;
    这句改为
    exports 
    function add1(Ai: Integer): Integer;
    试试看行不行
      

  2.   

    写错了,不好意思,
    应该写成这样
    exports add1;
      

  3.   

    to linzhengqun(linzhengqun):
      谢谢回复
      我一开始就使用exports add1;但是就是不行才改成exports add1 index 1;
      

  4.   

    給你個例子吧:
    Dll Source
    ========================
    Library Test;{ 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;
    {$R *.res}Function Hobbit(value:integer):integer; stdCall;
      begin
        Result:=Value+3;
      end;exports
    Hobbit;begin
    end.
    ============================================VB Source
    =============================================
    Option ExplicitPrivate Declare Function Hobbit Lib "C:\WINDOWS\Desktop\Test.dll" (ByVal Value As Integer) As IntegerPrivate Sub Command1_Click()
        MsgBox Hobbit(5)
    End Sub==============================
    調試成功,顯示為"8"
      

  5.   

    还是报错:实时错误 '453':
    找不到 DLL 入口点 Hobbit in Test.dll
      

  6.   

    那段代碼沒有問題,我在Win 98和2000中可以正確運行。是不是你有些小地方沒有注意?
      

  7.   

    to LiangWu25LiangWu25(水手) :
    我是在Windows XP环境下编译Delphi6代码的
      

  8.   

    沒裝XP,不辦法在那上面試。不過即使在XP環境下編譯也不會出什么錯吧?這個Dll很簡單呀。
    你試試不在VB下調用這個Dll,在Delphi下調用試試。這是我的測試代碼,是可以成功的。
    =============================================================================
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs,StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Edit1: TEdit;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    Function Hobbit(value:integer):integer;StdCall; external 'C:\WINDOWS\Desktop\Test.dll';
    procedure TForm1.Button1Click(Sender: TObject);
    begin
        edit1.Text:=inttostr(Hobbit(4));
    end;end.