LastErr J/Direct Sample

This sample is located in \Samples\JDirect\Lasterr.

Description
Using the Sample
Key Project Files
Technologies Demonstrated

Description

This sample shows how to capture the SetLastError error code from a Microsoft® Win32® API.

Using the Sample

To run the sample

Run Go.bat in the \Samples\JDirect\Lasterr directory.

Key Project Files

LastErr.java

This file contains a do-while loop in a try block in its main method that uses the SetLastError keyword.

It is not safe to call GetLastError yourself because the Microsoft virtual machine (Microsoft VM) can make API calls itself that overwrite the error value. Instead, you must use the SetLastError keyword to force the Microsoft VM to capture the error code and save it in a per-thread data block. This error code can then be retrieved using the getLastWin32Error method.

Technologies Demonstrated

J/Direct

This sample shows how to use the following:

© 1999 Microsoft Corporation. All rights reserved. Terms of use.