<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def winapi_result( result ):

 """Validate WINAPI BOOL result, raise exception if failed"""

    if not result:
        raise WinApiException("%d (%x): %s" % (ctypes.GetLastError(),
                ctypes.GetLastError(), ctypes.FormatError()))
    return result