uses: WinProcs, WinTypes, SysUtils;
var
ALibrary : THandle; //Windows uses handles for lots of things such as an open window or DLL
AFilename: string; ABuffer: array[0..255] of Char; //this is to convert Pascal string to PChar
aDLLFunctionName: function(parameter types):ReturnDataType; //this is a procedural-type variable!
//initialise variables:
AFilename := 'mylibrary.dll'; StrPCopy(ABuffer,AFilename);
@aDLLFunctionName := nil;
try
ALibrary := LoadLibrary(ABuffer);
if ALibrary > HINSTANCE_ERROR then
begin {its safe to use library}
//retrieve subroutine addresses:
@aDLLFunctionName := GetProcAddress(ALibrary, 'DLLFunctionName');
//use function:
if assigned(aDLLFunctionName) then
x := aDLLFunctionName(parameter values);
end
else {there was a problem}
finally FreeLibrary(ALibrary);
end;