Microsoft SDK for Java

sizeOf

The sizeOf method of the DllLib class contains the following signatures:

sizeOf(Class structCls)
sizeOf(Object structObj)

sizeOf(Class structCls)

Returns the size in bytes of the native structure represented by the specified class. The class must have been declared using the @dll.struct compiler directive (or @com.struct).

Syntax

public static int sizeOf(Class structCls);

Return Value

Returns the size of the native structure (in bytes).

Parameters

structCls The class to examine.

sizeOf(Object structObj)

Returns the size in bytes of an instance of a J/Direct structure.

Syntax

public native static int sizeOf(Object structObj);

Return Value

Returns the size of the object.

Parameters

structObj The object whose size is being determined.

You can use this method to declare a self-describing structure that will be used in a DLL call, as in the following example:

/** @dll.struct() */
class STARTUPINFO
{
  public int cb = DllLib.sizeOf(this);
  public int lpReserved;
  public int lpDesktop;
  ...
}

// now you can use an instance of STARTUPINFO in a DLL call

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