D
dwj_dd
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Max;
interface
function Min1(x,y,z:Integer):Integer;
stdcall;
function Max1(x,y,z:Integer):Integer;
stdcall;
implementation
function Min1;external 'MaxMin.DLL' name 'Min1';
function Max1;external 'MaxMin.DLL' name 'Max1';
end.
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
Ttestvcdll = class(TForm)
edtInt1: TEdit;
edtInt2: TEdit;
edtInt3: TEdit;
edtMax: TEdit;
edtMin: TEdit;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
testvcdll: Ttestvcdll;
implementation
uses Max;
{$R *.dfm}
procedure Ttestvcdll.Button1Click(Sender: TObject);
begin
edtMax.Text:=IntToStr(Max1(StrToInt(edtInt1.Text),
StrToInt(edtInt2.Text),StrToInt(edtInt3.Text)));
//调用动态链接库中的函数Max1
edtMin.Text:=IntToStr(Min1(StrToInt(edtInt1.Text),
StrToInt(edtInt2.Text),StrToInt(edtInt3.Text)));
//调用动态链接库中的函数Min1
end;
end.
program testvc;
uses
Forms,
main in 'main.pas' {testvcdll},
Max in 'Max.pas';
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(Ttestvcdll, testvcdll);
Application.Run;
end.
MyDll.cpp文件如下:
#include "stdafx.h"
#include "MyDll.h"
extern "C" _declspec(dllexport) int Min1(int x,int y,int z)
{
if ((x<=y) &
(x<=z)) return x;
else
if ((y<=x) &
(y<=z)) return y;
else
return z;
/*找出x,y,z中的最小整数*/
}
extern "C" _declspec(dllexport) int Max1(int x,int y,int z)
{
if ((x>=y) &
(x>=z)) return x;
else
if ((y>=x) &
(y>=z)) return y;
else
return z;
/*找出x,y,z中的最大整数*/
}
MyDll.h文件如下:
extern "C" _declspec(dllexport) int Min1(int x,int y,int z);
extern "C" _declspec(dllexport) int Max1(int x,int y,int z);
为什么一运行delphi程序,总是提示找不到Max1或Min1的入口点?????
显示调用和隐式调用我都试过了。
interface
function Min1(x,y,z:Integer):Integer;
stdcall;
function Max1(x,y,z:Integer):Integer;
stdcall;
implementation
function Min1;external 'MaxMin.DLL' name 'Min1';
function Max1;external 'MaxMin.DLL' name 'Max1';
end.
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
Ttestvcdll = class(TForm)
edtInt1: TEdit;
edtInt2: TEdit;
edtInt3: TEdit;
edtMax: TEdit;
edtMin: TEdit;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
testvcdll: Ttestvcdll;
implementation
uses Max;
{$R *.dfm}
procedure Ttestvcdll.Button1Click(Sender: TObject);
begin
edtMax.Text:=IntToStr(Max1(StrToInt(edtInt1.Text),
StrToInt(edtInt2.Text),StrToInt(edtInt3.Text)));
//调用动态链接库中的函数Max1
edtMin.Text:=IntToStr(Min1(StrToInt(edtInt1.Text),
StrToInt(edtInt2.Text),StrToInt(edtInt3.Text)));
//调用动态链接库中的函数Min1
end;
end.
program testvc;
uses
Forms,
main in 'main.pas' {testvcdll},
Max in 'Max.pas';
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(Ttestvcdll, testvcdll);
Application.Run;
end.
MyDll.cpp文件如下:
#include "stdafx.h"
#include "MyDll.h"
extern "C" _declspec(dllexport) int Min1(int x,int y,int z)
{
if ((x<=y) &
(x<=z)) return x;
else
if ((y<=x) &
(y<=z)) return y;
else
return z;
/*找出x,y,z中的最小整数*/
}
extern "C" _declspec(dllexport) int Max1(int x,int y,int z)
{
if ((x>=y) &
(x>=z)) return x;
else
if ((y>=x) &
(y>=z)) return y;
else
return z;
/*找出x,y,z中的最大整数*/
}
MyDll.h文件如下:
extern "C" _declspec(dllexport) int Min1(int x,int y,int z);
extern "C" _declspec(dllexport) int Max1(int x,int y,int z);
为什么一运行delphi程序,总是提示找不到Max1或Min1的入口点?????
显示调用和隐式调用我都试过了。