WIN32API GetLastError()

Mark Hammond mhammond at skippinet.com.au
Wed Jun 14 15:36:40 EDT 2000


In article <8i67nm$l37$12$1 at news.t-online.com>,
  "Eduard Hiti" <eduard.hiti at t-online.de> wrote:

[I really wish people would avoid CCing me when posting to the group.
Or if you must, please make sure you let me know, so I dont have to
waste time answering the same question twice!]

My original reply, which I clearly shouldnt have bothered sending:

The problem is that Python has printed a result between the CreateEvent
() call, and the GetLastError() call.  The GetLastError() of zero
almost certainly relates to the file IO used for either reading the
next command, or printing the result.

If I put the following code in a .py file:

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

When I run it, it yields:
183

Mark.
> -----Original Message-----
> From: Eduard Hiti [mailto:Eduard.Hiti at t-online.de]
> Sent: Tuesday, 13 June 2000 1:59 PM
> To: Mark Hammond
> Subject: Re: WIN32API GetLastError()
>
>
>
> >
> > 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
>
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list