Link to home
Create AccountLog in
Avatar of llarava
llaravaFlag for Afghanistan

asked on

GetLastError Win32

Somebody can provide some information about GetLastError Win32 function.

I need a list of this different errors that can be returned for this fucntion. Basically this function triggers messages in the description field of application node on the microsoft event log for a specific product that I am using.
I am setting up monitor for the Event Id number and  the message that I get in the description in the application node for the event id.
The vendor told me that this messages are based on Getlaserror win32 function. Is there a way to know about a list of this errors?  
Avatar of sj_hicks
Flag of Australia image

GetLastError will return the error number of the last Win32 error, but not the description.  An easy way I use is to throw a Win32 exception like this:

     Throw New System.ComponentModel.Win32Exception(errorcode)
 Catch ex As System.ComponentModel.Win32Exception
     MsgBox(ex.ErrorCode & vbNewLine & ex.ToString)
 End Try

The exception then gives you the decription etc.  Maybe not the best idea if you do it often, but works for me for occasional use.  Probably the recommended way is to use the FormatMessage API which will take an error code and return the description.
Avatar of F. Dominicus
One usually uses FormatMessage for that. Howerver in every MSVC I have seen till now is a small tool Error Lookup It's just a dialog with one text field in which you can put the Error code and you'll get the description for it. sj_hicks suggestion does more or less the same by-Script ;-)

Avatar of llarava


There is any vbs script or any tool that I can run in order to get this information.
Avatar of jkr
Flag of Germany image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
>>There is any vbs script or any tool that I can run in order to get this

Take a look at MS' error lookup tool, downloadable from