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.怎么不行呢?请指教!
#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.怎么不行呢?请指教!
解决方案 »
- dll中的资源文件如何加密
- 急()数据类型不匹配
- 谢谢.请教.TSoundIn TSoundOut谁用过?哪里有下载
- 请问下这个是什么错误啊?
- 怎么判断一个字符串是否在一个stringlist里面????
- ADOdataset 无法删除记录! 提示是commandtext 无法返回结果
- 我发现一个问题,也许只是我的才这样.在DELPHI7中,只要是有密码的MDB数据库,用ADO下面的所有控件都连接不了.
- 在DELPHI中,怎样检测SQL SERVER 2000中某个数据库是否存在?
- DBGrid的显示问题
- @记录集只读问题
- 你们好啊,你们中间有做管理的么,有自己开公司的么
- 知道对方的DTD文件,怎么把我的数据写成XML格式传给他?谢谢,急!急!急!!!
//---------------------------------------------------------------------------
#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.
begin
windowshow();
end;
begin
windowshow();
end;
你的dll里没有isShow()函数啊,怎么也这么声明了呢??
Form1: TForm1; function WindowShow():boolean; Stdcall;external 'ctsdll.dll';
dll要放在程序同一目录下,否则要注册。调用dll中的函数就和在自己程序中的一样就行了。