Solved

Format of a DLL (internal functions)

Posted on 2007-03-24
1
205 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
ID: 18786548
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Printing problem 2 94
Print Graphic and Text to Epson TM-T88v 12 259
Dev express lookupcombo 3 28
Firemonkey allowing RTL on android 6 32
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 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