Solved

Format of a DLL (internal functions)

Posted on 2007-03-24
1
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 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