Jump to content
xisto Community
Sign in to follow this  
Clinica do PC

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

Recommended Posts

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)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.