Using the Raw Native Interface Previous
Previous
Introduction
Introduction
Next
Next

Misc

To check if an object is of a particular type you can use isInstanceOf():

    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(), for 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(), for example to copy 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.

© 1996 Microsoft Corporation. All rights reserved.