Call a function in a shared library: Difference between revisions

Content added Content deleted
(GP)
(Added Delphi example)
Line 203: Line 203:
:pointer)
:pointer)
#.(SB-SYS:INT-SAP #X00650FD0)</lang>
#.(SB-SYS:INT-SAP #X00650FD0)</lang>

=={{header|Delphi}}==

===Static loading===
Loads library on startup.

<lang Delphi>procedure DoSomething; external 'MYLIB.DLL';</lang>


===Delayed loading===
Loads library on first call to DoSomething.

<lang Delphi>procedure DoSomething; external 'MYLIB.DLL' delayed;</lang>


===Dynamic loading===
Loads and unloads library on demand.

<lang Delphi>var
lLibraryHandle: THandle;
lDoSomething: procedure; stdcall;
begin
lLibraryHandle := LoadLibrary('MYLIB.DLL');
if lLibraryHandle >= 32 then { success }
begin
lDoSomething := GetProcAddress(lLibraryHandle, 'DoSomething');
lDoSomething();
FreeLibrary(lLibraryHandle);
end;
end;</lang>


=={{header|J}}==
=={{header|J}}==