Search in sources :

Example 6 with VARIANT

use of com.sun.jna.platform.win32.Variant.VARIANT in project jna by java-native-access.

the class VariantTest method testVariantDate.

public void testVariantDate() {
    SYSTEMTIME lpSystemTime = new SYSTEMTIME();
    Kernel32.INSTANCE.GetLocalTime(lpSystemTime);
    DoubleByReference pvtime = new DoubleByReference();
    OleAuto.INSTANCE.SystemTimeToVariantTime(lpSystemTime, pvtime);
    VARIANT variantDate = new VARIANT(new DATE(pvtime.getValue()));
}
Also used : DoubleByReference(com.sun.jna.ptr.DoubleByReference) DATE(com.sun.jna.platform.win32.OaIdl.DATE) SYSTEMTIME(com.sun.jna.platform.win32.WinBase.SYSTEMTIME) VARIANT(com.sun.jna.platform.win32.Variant.VARIANT)

Example 7 with VARIANT

use of com.sun.jna.platform.win32.Variant.VARIANT in project jna by java-native-access.

the class VariantTest method testVariantSafearrayWrapping.

public void testVariantSafearrayWrapping() {
    SAFEARRAY safearray = OaIdl.SAFEARRAY.createSafeArray(new VARTYPE(Variant.VT_I1), 5);
    try {
        VARIANT variant = new VARIANT(safearray);
        assertThat(variant.getVarType().intValue(), equalTo((int) (Variant.VT_I1 | Variant.VT_ARRAY)));
        Object wrappedValue = variant.getValue();
        assertThat(wrappedValue, instanceOf(SAFEARRAY.class));
        assertThat(safearray.getUBound(0), is(4));
    } finally {
        safearray.destroy();
    }
}
Also used : SAFEARRAY(com.sun.jna.platform.win32.OaIdl.SAFEARRAY) VARTYPE(com.sun.jna.platform.win32.WTypes.VARTYPE) VARIANT(com.sun.jna.platform.win32.Variant.VARIANT)

Example 8 with VARIANT

use of com.sun.jna.platform.win32.Variant.VARIANT in project jna by java-native-access.

the class VariantTest method testVariantClear.

public void testVariantClear() {
    VARIANT variant = new VARIANT(new SHORT(33333));
    HRESULT hr = OleAuto.INSTANCE.VariantClear(variant);
    assertTrue("hr: " + hr.intValue(), hr.intValue() == 0);
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) VARIANT(com.sun.jna.platform.win32.Variant.VARIANT) SHORT(com.sun.jna.platform.win32.WinDef.SHORT) USHORT(com.sun.jna.platform.win32.WinDef.USHORT)

Example 9 with VARIANT

use of com.sun.jna.platform.win32.Variant.VARIANT in project jna by java-native-access.

the class VariantTest method testVariantCopyShort.

public void testVariantCopyShort() {
    VARIANT variantSource = new VARIANT(new SHORT(33333));
    VARIANT variantDest = new VARIANT();
    //System.out.println(variantSource.toString(true));
    HRESULT hr = OleAuto.INSTANCE.VariantCopy(variantDest.getPointer(), variantSource);
    assertTrue("hr: " + hr.intValue(), hr.intValue() == 0);
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) VARIANT(com.sun.jna.platform.win32.Variant.VARIANT) SHORT(com.sun.jna.platform.win32.WinDef.SHORT) USHORT(com.sun.jna.platform.win32.WinDef.USHORT)

Example 10 with VARIANT

use of com.sun.jna.platform.win32.Variant.VARIANT in project jna by java-native-access.

the class MSExcel method insertValue.

public void insertValue(String range, String value) throws COMException {
    Range pRange = new Range(this.getAutomationProperty("Range", this.getActiveSheet(), new VARIANT(range)));
    this.setProperty("Value", pRange, new VARIANT(value));
}
Also used : VARIANT(com.sun.jna.platform.win32.Variant.VARIANT)

Aggregations

VARIANT (com.sun.jna.platform.win32.Variant.VARIANT)37 HRESULT (com.sun.jna.platform.win32.WinNT.HRESULT)12 ComObject (com.sun.jna.platform.win32.COM.util.annotation.ComObject)10 Test (org.junit.Test)10 DISPIDByReference (com.sun.jna.platform.win32.OaIdl.DISPIDByReference)6 SAFEARRAY (com.sun.jna.platform.win32.OaIdl.SAFEARRAY)6 IntByReference (com.sun.jna.ptr.IntByReference)6 PointerByReference (com.sun.jna.ptr.PointerByReference)6 REFIID (com.sun.jna.platform.win32.Guid.REFIID)5 DATE (com.sun.jna.platform.win32.OaIdl.DATE)5 BSTR (com.sun.jna.platform.win32.WTypes.BSTR)5 SHORT (com.sun.jna.platform.win32.WinDef.SHORT)5 IConnectionPoint (com.sun.jna.platform.win32.COM.util.IConnectionPoint)4 Variant (com.sun.jna.platform.win32.Variant)4 VT_VARIANT (com.sun.jna.platform.win32.Variant.VT_VARIANT)4 WinDef (com.sun.jna.platform.win32.WinDef)4 Pointer (com.sun.jna.Pointer)3 WString (com.sun.jna.WString)3 COMException (com.sun.jna.platform.win32.COM.COMException)3 ConnectionPoint (com.sun.jna.platform.win32.COM.ConnectionPoint)3