Kapusta
asked on
Format of a DLL (internal functions)
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).
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).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.