System.SysUtils.SafeLoadLibrary

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

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

C++

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

Properties

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

Description

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