Code: Select all
Procedure.s GetLastErrorStr(error.l = 0)
If Not error
error = GetLastError_()
EndIf
Protected Buffer.i, result.s
If FormatMessage_(#FORMAT_MESSAGE_ALLOCATE_BUFFER|#FORMAT_MESSAGE_FROM_SYSTEM,0,error,0,@Buffer,0,0)
result = PeekS(Buffer)
LocalFree_(Buffer)
ProcedureReturn result
EndIf
EndProcedure

greetings - Thomas