In an harddisk cleanup i (re)discovered an experiment from last year. Might be usefull.

Inspired by an article written by Max Kleiner ( http://www.delphi3000.com/articles/article_2708.asp?SK= ) i made an delphi hello world class example living inside an dll.

helloworldi.pas
[pascal]
unit helloworldi;

interface
type
THelloWorldI = class
public
function Say(): string; virtual ; abstract ;
end;

function CreateHelloWorld: THelloWorldI; cdecl; external 'HelloWorldLib.dll';

implementation
end.
[/pascal]

helloworld.pas
[pascal]
unit helloworld;

interface

uses helloworldi;

type
THelloWorld = class(THelloWorldI)
public
function Say(): string; override;
end;

implementation

function THelloWorld.Say(): string;
begin
Say := 'This is a test';
end;

end.
[/pascal]

helloworldlib.dpr
[pascal]
library HelloWorldLib;

uses
SysUtils,
Classes,
helloworld in 'helloworld.pas',
helloworldi in 'helloworldi.pas';

{$R *.res}

function CreateHelloWorld(): THelloWorldI; cdecl;
begin
result := THelloWorld.Create();
end;

exports
CreateHelloWorld;

begin
end.
[/pascal]

usage:
place helloworldi in the uses
in var: helloworld: THelloWorldI;
create an instance with: helloworld := CreateHelloWorld();
next use it: helloworld.Say();
and you get an hello world from a class living inside an dll.

i have yet to try to call the delphi dll from cpp.