VarDate Custom Marshaling Sample

This sample is located in \Samples\Com\CustomMarshal\Vardate.

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

Description

The VarDateMarshaler sample translates native parameters of type DATE to Java parameters of type java.util.Date. The JTYPE is java.util.Date. The ETYPE is the VARIANT date and time type, DATE, which is really a double.

This hook class is implemented completely in Java. It uses Microsoft® J/Direct™ to access the Microsoft® Win32® structure SYSTEMTIME, and it uses the API methods SystemTimeToVariantTime and VariantTimeToSystemTime to convert values of type DATE to and from values of type SYSTEMTIME. The fields within the SYSTEMTIME structure can be read or written to convert to and from instances of java.util.Date.

The hook class VarDateMarshaler can be used as described in the following table.

Hook class usage

COM type Marshaled to Java as
HRESULT func([in] DATE) func(java.util.Date)
HRESULT func([out,retval] DATE*) java.util.Date func()
HRESULT func([in] DATE*) func(java.util.Date)
HRESULT func([out] DATE*) func(java.util.Date[])
HRESULT func([in,out] DATE*) func(java.util.Date[])

Because instances of Date are not easily mutable, the const modifier should be used for them in the .jnf file supplied to jactivex.

Note also that jactivex cannot generate classes that use hook classes for parameters of primitive types, such as DATE. You must change the primitive DATE type to a structure type containing a DATE field, which jactivex can handle correctly. See the file VarDate.idl in the \Samples\Com\CustomMarshal\Vardate directory.

Using the Sample

To compile the sample

Use Nmake.exe to compile the makefile in the \Samples\Com\CustomMarshal\Vardate directory. Type the following command:

Nmake

To run the sample

Run VarDate.exe from the \Samples\Com\CustomMarshal\Vardate directory.

Technologies Demonstrated

Custom Marshaling

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