Delphi example
How create a DLL
unit MyLibrary; interface // Exported function function AddNumbers(a, b: Integer): Integer; stdcall; implementation // Function implementation function AddNumbers(a, b: Integer): Integer; stdcall; begin Result := a + b; end; exports AddNumbers; end.
How use a DLL
// Load the DLL DLLHandle := LoadLibrary('YourDLLName.dll'); // Check if the DLL is loaded successfully if DLLHandle <> 0 then begin try // Get the function address from the DLL @AddNumbers := GetProcAddress(DLLHandle, 'AddNumbers'); // Check if the function is obtained successfully if Assigned(AddNumbers) then begin // Now you can use the AddNumbers function as if it's a regular Delphi function ShowMessage('Result: ' + IntToStr(AddNumbers(3, 4))); end else begin ShowMessage('Failed to obtain function address from DLL.'); end; finally // Unload the DLL when done FreeLibrary(DLLHandle); end; end else begin ShowMessage('Failed to load DLL.'); end;