Using the Raw Native Interface Previous
Previous
Introduction
Introduction
Index
Index

Miscellaneous

To check if an object is of a particular type, you can use isInstanceOf() as shown in the following example:

    if (isInstanceOf(phSomeObject, "java/awt/Rectangle"))
    {
        // Object is a Rectangle...
    }

The first parameter is an object pointer and the second parameter is the full class name you want to test against.

Given a Java String, you can query the number of Java characters it contains with javaStringLength(). For example:

    int cchString = javaStringLength(phString);

Given a Java String, you can copy it to a C string buffer (converting from Unicode to multi-byte characters (on the way) using javaString2CString(). This is shown in the following example:

    char szMBCS[256];

    javaString2CString(phString, szMBCS, sizeof(szMBCS);

The first parameter is the String object, the second is the destination buffer, and the third is the size of the buffer (in bytes), including the terminating NULL.

Given two arrays, you can copy from one to the other using ArrayCopy(). The following is an example of copying 10 elements from one array, starting at position 3, to another, starting at position 5:

    ArrayCopy(phabSrc, 3, phabDst, 5, 10);

The first parameter is the source array, the second parameter is the source offset, the third is the destination array, the fourth is destination offset, and the fifth is the number of elements to copy.

© 1997 Microsoft Corporation. All rights reserved. Legal Notices.