VC写的DLL头文件及输出函数如下:#ifndef _CTSDLL_H
#define _CTSDLL_H
extern "C"  __declspec(dllexport) BOOL WindowShow();#endif我的DELPHI代码如下:
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, 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;  function isShow():boolean; Stdcall;external 'ctsdll.dll';implementation{$R *.dfm}
function isShow():boolean;stdcall;external 'ctsdll.dll';
begin
  windowshow();
end;procedure TForm1.Button1Click(Sender: TObject);
begin
  isShow();
end;end.怎么不行呢?请指教!

解决方案 »

  1.   

    C++中:
    //---------------------------------------------------------------------------
    #include <vcl.h>
    #pragma hdrstopint WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
    {
        return 1;
    }//---------------------------------------------------------------------------extern "C" __declspec(dllexport)
    int WINAPI Double (int n)
    {
    return n * 2;
    }extern "C" __declspec(dllexport)
    int WINAPI Triple (int n)
    {
    return n * 3;
    }__declspec(dllexport)
    int WINAPI Add (int a, int b)
    {
    return (a + b);
    }
    Delphi中:
    implementation{$R *.DFM}{definition of the functions of the DLL}
    function Add (A, B: Integer): Integer;
      stdcall; external 'CPPDLL.DLL' name '@Add$qqsii';
    function Double (N: Integer): Integer;
      stdcall; external 'CPPDLL.DLL' name 'Double';
    function Triple (N: Integer): Integer;
      stdcall; external 'CPPDLL.DLL';procedure TForm1.BtnDoubleClick(Sender: TObject);
    begin
      SpinEdit1.Value := Double (SpinEdit1.Value);
    end;procedure TForm1.BtnTripleClick(Sender: TObject);
    begin
      SpinEdit2.Value := Triple (SpinEdit2.Value);
    end;procedure TForm1.BtnAddClick(Sender: TObject);
    begin
      Edit1.Text := IntToStr (Add (
        SpinEdit1.Value, SpinEdit2.Value));
    end;end.
      

  2.   

    function WindowShow():boolean; Stdcall;external 'ctsdll.dll';implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
      windowshow();
    end;
      

  3.   

    function WindowShow():boolean; Stdcall;external 'ctsdll.dll';这里的声明应与dll中的一样@
      

  4.   

    function isShow():boolean;stdcall;external 'ctsdll.dll';
    begin
      windowshow();
    end;
    你的dll里没有isShow()函数啊,怎么也这么声明了呢??
      

  5.   

    var
      Form1: TForm1;  function WindowShow():boolean; Stdcall;external 'ctsdll.dll';
    dll要放在程序同一目录下,否则要注册。调用dll中的函数就和在自己程序中的一样就行了。