Use of Delphi DLLs

Source: Internet
Author: User

DLL definition

LibrarySUM;{Important Note about DLL memory Management:sharemem must is the first unit in your library ' s USES clause and your P Roject ' s (select Project-view Source) USES clause If your DLL exports any procedures or functions this pass strings as P Arameters or function results. This is dll--even in those and nested, applies to all strings passed to and from your records classes. SHAREMEM is the interface unit to the BORLNDMM. DLL shared Memory manager, which must is deployed along with your DLL. To avoid using BORLNDMM. DLL, pass string information using PChar or shortstring parameters. }usessysutils, Classes, Uni_dllfileinch 'Uni_dllfile.pas';{$R *.res}  exportssum1;beginEnd.

Unit Uni_dllfile; Interface  function sum1 (a,b:integer): Integer; stdcall ; implementation  function sum1 (A,b:integer): Integer;   begin     Result:=a+b;   End ;   End.

Call

Unituni_sum;InterfaceusesWindows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls;typeTForm1=class(tform) Edit2:tedit;    Label1:tlabel;    Button1:tbutton;    Edit3:tedit;    Edit1:tedit; procedureButton1Click (Sender:tobject); Private    {Private Declarations}   Public    {Public Declarations}  End;varForm1:tform1;Implementation   functionSUM1 (A,b:integer): Integer;stdcall;External 'Dall_pak\sum.dll';{$R *.DFM}procedureTform1.button1click (sender:tobject);beginedit3. Text:=IntToStr (sum1 (Strtoint (edit1. Text), Strtoint (edit2. Text ));End;End.

Use of Delphi DLLs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.