Cross platform FormatMessage function lazarus / 7-LCL ---------------------------------------------------------------------- Leledumbo · 2008-05-22 05:07 Is there any cross platform alternative to WINAPI's FormatMessage? I have an IDE project with embedded terminal (made with TCmdBox) with each command is processed by TProcess. Using try-except block where on except I write the exception message, I got (for instance): Failed to execute XXX : 2 With FormatMessage, I can make it to: The system cannot find the file specified. Much clearer, isn't it? But I don't seem to find the same function for other OSes. ---------------------------------------------------------------------- Paul Ishenin · 2008-05-26 06:35 Have you seen rtl Format function? ---------------------------------------------------------------------- Leledumbo · 2008-05-26 07:06 rtl? Isn't that SysUtils function? ---------------------------------------------------------------------- Paul Ishenin · 2008-05-27 01:17 yes ---------------------------------------------------------------------- Leledumbo · 2008-05-27 03:47 EProcess is raised with that function as the message formatter, I just simply parse the error code after the colon and pass it to FormatMessage. The error code is system dependent (CMIIW, but does Linux defines 2 as "File not found"?), every OS has its own code for particular error. If only LCL/FCL/RTL has this kind of function, I mean something like: Code: [Select] function OSErrorMsg(const ErrorCode: Integer): String; var   Buf: PChar; begin {$ifdef windows} FormatMessage(   ... ) Result:=StrPas(Buf); {$else} ... {$endif} end;