The sizeOf method of the DllLib class contains the following signatures:
sizeOf(Class structCls)
sizeOf(Object structObj)
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).
public static int sizeOf(Class structCls);
Returns the size of the native structure (in bytes).
structCls | The class to examine. |
Returns the size in bytes of an instance of a J/Direct structure.
public native static int sizeOf(Object structObj);
Returns the size of the object.
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