[API]
LocalAlloc
FormatMessageW
FormatMessageA
LocalFree

[INCLUDE]
TemporaryMemory
PeekS

[CODE]
Public Function FormatMessage(ByVal dwFlags As Long, ByVal lpSource As Long, ByVal dwMessageId As Long) As String
  If IsUnicode Then
    dwFlags = FormatMessageW(dwFlags, ByVal lpSource, dwMessageId, 0&, ptrTemp, ptrTempSizeXW, 0&)
    Else
    dwFlags = FormatMessageA(dwFlags, ByVal lpSource, dwMessageId, 0&, ByVal ptrTemp, ptrTempSizeX, 0&)
    End If
  If Not dwFlags = 0& Then FormatMessage = PeekS(ptrTemp, dwFlags)
  End Function
