Solved

Format of a DLL (internal functions)

Posted on 2007-03-24
1
203 Views
Last Modified: 2010-04-05
I'm rather lost in my first attempt to create a Delphi 5 DLL.

Yes, I can run through the wizard and get the following barebones shell for my library...

// ===========================
library test;

uses
  SysUtils, Classes;

{$R *.RES}

function TestStrings(FirstParam: ShortString; SecondParam: ShortString):ShortString; stdcall;
begin
  Result := FirstParam + ', ' + SecondParam;
end;

exports TestStrings;

begin
end.

// ===========================

Everything is fine...until I want to start adding more code.

For instance, I am lost as to how to add new INTERNAL functions/procedures.  IOW, if I wanted the TestStrings function to use another function, which will only be used within the DLL and NOT be exported, then where/how does one define the function?  Do I do this...

// ===========================
library test;

uses
  SysUtils, Classes;

function AddBrackets(TextIn : ShortString) : ShortString;

{$R *.RES}

function TestStrings(FirstParam: ShortString; SecondParam: ShortString):ShortString; stdcall;
begin
  Result := FirstParam + ', ' + SecondParam;
end;

function AddBrackets(TextIn : ShortString) : ShortString;
begin
  Result := '<' + TextIn + '>';
end;

exports TestStrings;

begin
end.

// ===========================


...or this...

// ===========================
library test;

uses
  SysUtils, Classes;

function AddBrackets(TextIn : ShortString) : ShortString;

{$R *.RES}

function TestStrings(FirstParam: ShortString; SecondParam: ShortString):ShortString; stdcall;
begin
  Result := FirstParam + ', ' + SecondParam;
end;

exports TestStrings;

begin

function AddBrackets(TextIn : ShortString) : ShortString;
begin
  Result := '<' + TextIn + '>';
end;

end.

// ===========================

Neither of the above will compile, with the last example above generating the compile error "EXPORTS allowed only at global"

I can't find anything via googling that provides primer information regarding where to place INTERNAL functions/procedures in respect to exported function(s).
0
Comment
Question by:Kapusta
1 Comment
 
LVL 15

Accepted Solution

by:
mikelittlewood earned 125 total points
Comment Utility
Do you only want to use it within the same function or for many?
If so you can embed procedures inside other procedures.

function TestStrings(FirstParam: ShortString; SecondParam: ShortString):ShortString; stdcall;

   function AddBrackets(TextIn : ShortString) : ShortString;
   begin
     Result := '<' + TextIn + '>';
   end;

begin
  Result := AddBrackets( FirstParam + ', ' + SecondParam);
end;
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ADO Memory leak with DELPHI 2007 37 153
Newbie Thread Programming 1 116
Delphi: how to send PJL commands to printer 3 79
LAN or WAN ? 11 58
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now