Packages
 In this topic

*Constructors

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.dll   Previous This
Package
Next

 


Class Callback

public class Callback
{
  // Constructors
  protected Callback();

  // Methods
  protected void finalize();
}

This class creates a native callback for Win32 APIs such as EnumWindows. The Callback class can only be instantiated by a subclass constructor. Therefore, you must extend this class to use it. Each subclass must include a non-static method named callback, whose parameters are all integers and whose return type is either int or void. If a method that meets these requirements cannot be found anywhere in the inheritance hierarchy, construction will fail.

The callback method that is declared in a subclass creates a native callback that accepts as many 4-byte parameters as there are integer parameters to the callback method. The native callback returns a single 4-byte value, and that is the value returned by the callback method. If the callback method throws an uncaught Java exception, a zero is returned to the callback method's native caller.

To implement callbacks that take non-integer arguments such as strings or structures, you need to convert the integer argument (which typically corresponds to a native pointer) to a convenient Java type.

The Callback class is generally used for callbacks that exist only during the call of a single API. However, this class can also be used for persistent callbacks as long as you ensure that there is at least one Java reference to the Callback object for as long as the native code needs the callback.

For examples that show how you can declare and invoke DLL functions that take callbacks, see the Callbacks section of the Microsoft® J/Direct™ article.

Constructors

Callback

protected Callback();

Creates a Callback object. Since you must extend the Callback class to instantiate it, this constructor is used only by subclass constructors.

Methods

finalize

protected void finalize();

Performs cleanup before garbage collection.

Return Value:

No return value.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.