Stworzyłem w C++ Builderze bibliotekę dll:
//---------------------------------------------------------------------------
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused
//---------------------------------------------------------------------------
double BoxArea(double L, double H, double W);
double BoxVolume(double L, double H, double W);
extern "C" __declspec(dllexport)void BoxProperties(double Length, double Height,
double Width, double& Area, double& Volume);
//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
double BoxArea(double L, double H, double W)
{
return 2 * ((L*H) + (L*W) + (H*W));
}
//---------------------------------------------------------------------------
double BoxVolume(double L, double H, double W)
{
return L * H * W;
}
//---------------------------------------------------------------------------
void BoxProperties(double L, double H, double W, double& A, double& V)
{
A = BoxArea(L, H, W);
V = BoxVolume(L, H, W);
}
//---------------------------------------------------------------------------
W ten sposób powstała biblioteka my_dll.dll
Dalej, chciałem ją wykorzystać w Delphi:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Area,Volume: Real;
end;
var
Form1: TForm1;
procedure BoxProperties(L:real; H:real; W:real; var A:real; var V:real); stdcall; external 'my_dll.dll';
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
BoxProperties(1,1,1,Area,Volume);
Edit1.Text:=FloatToStr(Area);
end;
end.
Jednak podczas kompilacji wywala mi okno z błądem: "Nie znaleziono punktu wejścia procedury BoxProperties w bibliotece my_dll.dll"
Czym jest to spowodowane ??? Czy źle wywołuję procedurę ??
Pozdrawiam.
KOchzg