Since Delphi 2005, one can use the Library item in the Item Categories: "Delphi for .NET Projects", in the New Items dialog, to allow Delphi Win32 applications to access any Delphi for .NET routine.
All exported .NET routines are seen as stdcall routines on the Win32 side.
For example, to marshal strings between Delphi for .NET and Delphi Win32, here's a few ways:
library MyNETLibrary; // Delphi for .NET Library
{$UNSAFECODE ON}uses System.Runtime.InteropServices;procedure Hello1([MarshalAs(UnmanagedType.LPWStr)]S: String);begin System.Console.WriteLine('Hello, ' + S);end;procedure Hello2([MarshalAs(UnmanagedType.LPStr)]S: string);begin System.Console.WriteLine('Hello, ' + S);end;function SomeWideStringFunc1: string;begin Result := 'This is some string 1';end;[result: MarshalAs(UnmanagedType.LPStr)]function SomeWideStringFunc2: string;begin Result := 'This is some string 2';end;
exports SomeWideStringFunc1, SomeWideStringFunc2, Hello1, Hello2;
// Delphi for Win32 declarations
function SomeWideStringFunc1: PWideChar; external MyLib name 'SomeWideStringFunc1';function SomeWideStringFunc2: PChar; external MyLib name 'SomeWideStringFunc2';procedure Hello1(S: PWideChar); stdcall; external MyLib name 'Hello1';procedure Hello2(S: string); stdcall; external MyLib name 'Hello2';
In 2017, with the release of Delphi 10.2 Tokyo, Embarcadero introduced a specialized implementation of the Observer pattern into the System.Classes unit. While it has been in the wild for 9 years, it remains a "hidden" architecture for many, primarily because it serves as the invisible engine behind LiveBindings. Other than live bindings, you can also use the Observer pattern as a way to update component settings to the Windows registry, an .ini file, or persist it elsewhere.
System.Classes