#include <windows.h>

FormatWinMessage(int nMessageID)
{
    char szBuffer[512];
    int  length;
    length = FormatMessage(
        FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE,
        NULL,
        nMessageID,
        MAKELANGID(0, SUBLANG_ENGLISH_US),
        szBuffer,
        sizeof(szBuffer),
        NULL);
    if (length == 0)
    {
        int status = GetLastError();
        sprintf(szBuffer, "Error code %d", nMessageID);
    }
    return szBuffer;
}

