HOME       >>       Programming

How To Call A Dll From Delphi Last article I showed how to create a DLL, now we are going to learn h


Clinica do PC

In this example, we are going to use a Form, 2 text box (which the user should enter the both real numbers) and a button. See the Source example:

 

unit usadll;

 

interface

 

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;

 

type

TForm1 = class(TForm)

Label1: TLabel;

Label2: TLabel;

Button1: TButton;

Edit1: TEdit;

Edit2: TEdit;

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

function Max(a, b : double):double;stdcall;

 

var

Form1: TForm1;

 

implementation

 

{$R *.DFM}

 

function Max(a, b : double):double;external 'MaxDLL';

procedure TForm1.Button1Click(Sender: TObject);

var

x, y, resultado : double;

begin

x := StrToFloat(Edit1.Text);

y := StrToFloat(Edit2.Text);

resultado := Max(x,y);

ShowMessage('Valor Máximo ' +FloatToStr(resultado));

end;

 

end.

 

(That's it.. Thank you)



VIEW DESKTOP VERSION REGISTERGET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.