This sample is located in \Samples\Com\CustomMarshal\Fixedpt.
Note To use this sample, it is recommended that you have Microsoft® Visual C++® version 5.0 or higher installed.
Description
Using the Sample
Technologies Demonstrated
The FixedPtMarshaler sample is the simplest useful hook class. As shown in FixedPtMarshaler.java, it exposes only two methods and one field. The JTYPE is double, and the ETYPE is the Microsoft® Win32® FIXED structure for representing fixed point fractions.
The following table shows how FixedPtMarshaler methods marshal to Java methods.
COM type | Marshaled to Java as |
HRESULT func([in] FIXED) | func(double) |
HRESULT func([out,retval] FIXED*) | double func() |
HRESULT func([in] FIXED*) | func(double) |
HRESULT func([out] FIXED*) | func(double[]) |
HRESULT func([in,out] FIXED*) | func(double[]) |
When using FixedPtMarshaler in a .jnf file, precede the Java type double with the const modifier as in the following example:
[Custom] FIXED=const double, FixedPtMarshaler
If you don't include the const modifier, jactivex marshals the COM type HRESULT func([out] FIXED*) to Java as func(double).
This is not what you want. Because double is immutable, this method prototype cannot return a value to the caller.
To compile the sample
Use Nmake.exe to compile the makefile in the \Samples\Com\CustomMarshal\fixedpt directory. Type the following command:
Nmake
To run the sample
Run Go.bat from the \Samples\Com\CustomMarshal\rundir directory.