From RAD Studio API Documentation
Jump to: navigation, search


function SafeLoadLibrary(const Filename: string; ErrorMode: UINT): HMODULE;


extern DELPHI_PACKAGE unsigned __fastcall SafeLoadLibrary(const System::UnicodeString FileName, unsigned ErrorMode = (unsigned)(0x8000));


Type Visibility Source Unit Parent
function public
System.SysUtils System.SysUtils


Safe and simple library loading function.

SafeLoadLibrary loads a Windows dynamic linked library (DLL) or MAC OS X shared object file, as specified by the FileName parameter. SafeLoadLibrary preserves the current FPU control word, preventing library initialization code from permanently overwriting precision and exception masks.

Note: On Windows, SafeLoadLibrary temporarily sets the system error mode to ErrorMode. The default, SEM_NOOPENFILEERRORBOX, suppresses error dialogs. The previous error mode is restored before SafeLoadLibrary exits. For a list of error modes, refer to the SetErrorMode function in the Microsoft documentation. On OS X, the Dummy parameter is ignored.

In case of success, SafeLoadLibrary returns a handle to the loaded module. Otherwise, it returns NULL.

See Also