be.cardon.nativecall
Class LastError

java.lang.Object
  extended by be.cardon.nativecall.LastError

public class LastError
extends java.lang.Object

Wrapped class for GetLastError Windows API function.

This class is used in your JNI C or C++ code when a API function failed, returning FALSE. Your JNI code must call setLastError.

This class was created because the GetLastError() function must be called in the same thread as that generated the error. But two calls to native function are made in separated thread. So the called to GetLastError() must be made directly in the exception handling function.

The error number is documented in WinError.h. This file is available in the Microsoft Plateform SDK for Windows 2003 or other version. The description of these errors with a particular function is documented in the MSDN library (online or distributed with SDK's).


Constructor Summary
LastError()
           
 
Method Summary
static int getLastError()
          Get the last error number.
static java.lang.String getLastErrorHex()
          Get the last error number in decimal if 0 < error < 13884, otherwise in hexadecimal.
static void reset()
          Reset the last error number to zero.
static void setLastError(int errorNumber)
          Set the last error number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LastError

public LastError()
Method Detail

setLastError

public static void setLastError(int errorNumber)
Set the last error number.


getLastError

public static int getLastError()
Get the last error number. Call the reset method after reading the last error number.


getLastErrorHex

public static java.lang.String getLastErrorHex()
Get the last error number in decimal if 0 < error < 13884, otherwise in hexadecimal.


reset

public static void reset()
Reset the last error number to zero.