On Sat, 4 Oct 2014, Jürgen Hestermann wrote:
In my programs I use this code quite often: SysErrorMessage(GetLastError); A closer look at SysErrorMessage shows that the ERRORCODE will not be used in this routine but only handed over to FormatMessageA which expects a DWORD! ----------------------------------------------------------- function FormatMessageA(dwFlags:DWORD; lpSource:LPCVOID; dwMessageId:DWORD; <----- 3rd Parameter dwLanguageId:DWORD; lpBuffer:LPSTR; nSize:DWORD;Arguments:va_list):DWORD; external 'kernel32' name 'FormatMessageA';----------------------------------------------------------- So if GetLastError gives a DWORD and FormatMessageA expects a DWORD shouldn't SysErrorMessage use a DWORD too?
Not necessarily, because it is a cross-platform function and on other systems the error codes are not necessarily positive values. Unfortunately, this kind of windows-api-creep is found throughout the RTL. The proper procedure is probably to introduce TSysErrorCode which depends on the platform, and replace integer/dword with that. Please file a bug-report, so we do not forget this. Michael.
_______________________________________________ fpc-pascal maillist - [email protected] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
