WIN32API GetLastError()

Eduard Hiti eduard.hiti at t-online.de
Tue Jun 13 17:03:16 EDT 2000


>
> Note that many functions DO NOT support GetLastError() - they return
> the error code in a result, so it is pointless.  GetLastError() is
> mainly used for functions that return bools, or (say) handles, where
> only failure is indicated, and not the specific failure.
>

I had problems with win32api.GetLastError, too. Try this code:

    >>> a = win32event.CreateEvent(None, 0, 0, "Test")
    >>> b = win32event.CreateEvent(None, 0, 0, "Test")
    >>> win32api.GetLastError()
    0
    >>>

This is said in MSDN about CreateEvent:
If the function succeeds, the return value is a handle to the event object.
If the named event object existed before the function call, the function
returns a handle to the existing object and GetLastError returns
ERROR_ALREADY_EXISTS.

But obviously win32api.GetLastError does not return ERROR_ALREADY_EXISTS.

I helped myself by using OpenEvent and catching exceptions, but it seems
that GetLastError is problematic.

Bye,

    Eduard







More information about the Python-list mailing list