WIN32API GetLastError()

Mark Hammond mhammond at skippinet.com.au
Tue Jun 13 14:47:22 EDT 2000


In article <8i3460$ppm at news.or.intel.com>,
  "Jeff" <no_spam at umich.edu> wrote:

> ther than 0.  I am suspecting that this means that the GetLastError
> it is trying to "get" is an error from the pythonwin process
> and not from an API call I make (example writing to a file when
> only read access was given, or from an extension).  So my question

win32api.GetLastError() simply wraps the API function.  The error is
for the last function called, if it supports 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.

> is, what can GetLastError be used for,
> and is it at all possible to get the windows error code from a bad
> win32file.CreateFile??

I believe not - I dont think CreateFile uses GetLastError.  Note that
if CreateFile fails, an exception will be raised with the error code -
so GetLastError() is not necessary anyway - simply get it from the
exception.

Mark.


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



More information about the Python-list mailing list