[fpc-pascal] Syserrormessage, parameter data type

Sven Barth pascaldragon at googlemail.com
Mon Oct 6 07:55:34 CEST 2014


On 06.10.2014 07:20, Jürgen Hestermann wrote:
>
> Am 2014-10-05 um 20:21 schrieb Sven Barth:
>> Please note that GetLastError is Windows-specific. The cross platform
>> function in SysUtils is called GetLastOSError which does return Integer.
> And why does a function SysErrorMessage exist that expects an INTEGER
> and handes this over to FormatMessage which expects a DWORD?

SysErrorMessage is the cross platform function while FormatMessage is 
the Windows specific implementation so the types returned/used by these 
two functions are already compatible. GetLastOSError merely uses 
GetLastError on Windows (on Linux it is errno for example) and casts its 
DWORD result to Integer. SysErrorMessage gets that Integer passed in and 
converts it to DWORD again for FormatMessage on Windows (on Linux it 
uses a resourcestring table indexed by the error number for example).

Regards,
Sven




More information about the fpc-pascal mailing list