Search in sources :

Example 1 with BSTRByReference

use of com.sun.jna.platform.win32.WTypes.BSTRByReference in project jna by java-native-access.

the class ITypeInfoTest method testGetMops.

@Test
public void testGetMops() {
    ITypeInfo typeInfo = getTypeInfo();
    MEMBERID memid = new MEMBERID(0);
    BSTRByReference pBstrMops = new BSTRByReference();
    HRESULT hr = typeInfo.GetMops(memid, pBstrMops);
    COMUtils.checkRC(hr);
    assertEquals(0, hr.intValue());
//System.out.println("pBstrMops: " + pBstrMops.toString());
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) MEMBERID(com.sun.jna.platform.win32.OaIdl.MEMBERID) BSTRByReference(com.sun.jna.platform.win32.WTypes.BSTRByReference) Test(org.junit.Test)

Example 2 with BSTRByReference

use of com.sun.jna.platform.win32.WTypes.BSTRByReference in project jna by java-native-access.

the class ITypeInfoTest method testGetDocumentation.

@Test
public void testGetDocumentation() {
    ITypeInfo[] typeInfos = getTypeInfos();
    MEMBERID memid = new MEMBERID(0);
    BSTRByReference pBstrName = new BSTRByReference();
    BSTRByReference pBstrDocString = new BSTRByReference();
    DWORDByReference pdwHelpContext = new DWORDByReference();
    BSTRByReference pBstrHelpFile = new BSTRByReference();
    for (ITypeInfo typeInfo : typeInfos) {
        HRESULT hr = typeInfo.GetDocumentation(memid, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
        if (COMUtils.SUCCEEDED(hr)) {
            //System.out.println("pBstrHelpFile: " + pBstrHelpFile.getValue());
            return;
        }
    }
    throw new RuntimeException("Didn't find documentation in any of the type infos");
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) MEMBERID(com.sun.jna.platform.win32.OaIdl.MEMBERID) DWORDByReference(com.sun.jna.platform.win32.WinDef.DWORDByReference) BSTRByReference(com.sun.jna.platform.win32.WTypes.BSTRByReference) Test(org.junit.Test)

Example 3 with BSTRByReference

use of com.sun.jna.platform.win32.WTypes.BSTRByReference in project jna by java-native-access.

the class TypeInfoUtil method GetDllEntry.

/**
     * Gets the dll entry.
     * 
     * @param memid
     *            the memid
     * @param invKind
     *            the inv kind
     * @return the dll entry
     */
public DllEntry GetDllEntry(MEMBERID memid, INVOKEKIND invKind) {
    BSTRByReference pBstrDllName = new BSTRByReference();
    BSTRByReference pBstrName = new BSTRByReference();
    WORDByReference pwOrdinal = new WORDByReference();
    HRESULT hr = this.typeInfo.GetDllEntry(memid, invKind, pBstrDllName, pBstrName, pwOrdinal);
    COMUtils.checkRC(hr);
    OLEAUTO.SysFreeString(pBstrDllName.getValue());
    OLEAUTO.SysFreeString(pBstrName.getValue());
    return new DllEntry(pBstrDllName.getString(), pBstrName.getString(), pwOrdinal.getValue().intValue());
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) BSTRByReference(com.sun.jna.platform.win32.WTypes.BSTRByReference) DWORDByReference(com.sun.jna.platform.win32.WinDef.DWORDByReference) WORDByReference(com.sun.jna.platform.win32.WinDef.WORDByReference)

Example 4 with BSTRByReference

use of com.sun.jna.platform.win32.WTypes.BSTRByReference in project jna by java-native-access.

the class EnumMoniker method iterator.

@Override
public Iterator<IDispatch> iterator() {
    return new Iterator<IDispatch>() {

        @Override
        public boolean hasNext() {
            return null != EnumMoniker.this.rawNext;
        }

        @Override
        public IDispatch next() {
            assert COMUtils.comIsInitialized() : "COM not initialized";
            final Moniker moniker = EnumMoniker.this.rawNext;
            final PointerByReference ppunkObject = new PointerByReference();
            WinNT.HRESULT hr = EnumMoniker.this.rawRot.GetObject(moniker.getPointer(), ppunkObject);
            COMUtils.checkRC(hr);
            // To assist debug, can use the following code
            // PointerByReference ppbc = new
            // PointerByReference();
            // Ole32.INSTANCE.CreateBindCtx(new DWORD(), ppbc);
            //
            // BSTRByReference ppszDisplayName = new
            // BSTRByReference();
            // hr = moniker.GetDisplayName(ppbc.getValue(),
            // moniker.getPointer(), ppszDisplayName);
            // COMUtils.checkRC(hr);
            // String name = ppszDisplayName.getString();
            // Ole32.INSTANCE.CoTaskMemFree(ppszDisplayName.getPointer().getPointer(0));
            // TODO: Can we assume that the object is an
            // IDispatch ?
            // Unknown unk = new
            // Unknown(ppunkObject.getValue());
            Dispatch dispatch = new Dispatch(ppunkObject.getValue());
            EnumMoniker.this.cacheNext();
            IDispatch d = EnumMoniker.this.factory.createProxy(IDispatch.class, dispatch);
            //must release a COM Ref, GetObject returns a pointer with +1
            int n = dispatch.Release();
            return d;
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException("remove");
        }
    };
}
Also used : IEnumMoniker(com.sun.jna.platform.win32.COM.IEnumMoniker) Moniker(com.sun.jna.platform.win32.COM.Moniker) PointerByReference(com.sun.jna.ptr.PointerByReference) Iterator(java.util.Iterator) WinNT(com.sun.jna.platform.win32.WinNT) Dispatch(com.sun.jna.platform.win32.COM.Dispatch)

Example 5 with BSTRByReference

use of com.sun.jna.platform.win32.WTypes.BSTRByReference in project jna by java-native-access.

the class TypeLibUtil method getDocumentation.

/**
     * Gets the documentation.
     * 
     * @param index
     *            the index
     * @return the documentation
     */
public TypeLibDoc getDocumentation(int index) {
    BSTRByReference pBstrName = new BSTRByReference();
    BSTRByReference pBstrDocString = new BSTRByReference();
    DWORDByReference pdwHelpContext = new DWORDByReference();
    BSTRByReference pBstrHelpFile = new BSTRByReference();
    HRESULT hr = typelib.GetDocumentation(index, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
    COMUtils.checkRC(hr);
    TypeLibDoc typeLibDoc = new TypeLibDoc(pBstrName.getString(), pBstrDocString.getString(), pdwHelpContext.getValue().intValue(), pBstrHelpFile.getString());
    OLEAUTO.SysFreeString(pBstrName.getValue());
    OLEAUTO.SysFreeString(pBstrDocString.getValue());
    OLEAUTO.SysFreeString(pBstrHelpFile.getValue());
    return typeLibDoc;
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) DWORDByReference(com.sun.jna.platform.win32.WinDef.DWORDByReference) BSTRByReference(com.sun.jna.platform.win32.WTypes.BSTRByReference)

Aggregations

BSTRByReference (com.sun.jna.platform.win32.WTypes.BSTRByReference)7 HRESULT (com.sun.jna.platform.win32.WinNT.HRESULT)7 DWORDByReference (com.sun.jna.platform.win32.WinDef.DWORDByReference)5 MEMBERID (com.sun.jna.platform.win32.OaIdl.MEMBERID)3 Test (org.junit.Test)3 WORDByReference (com.sun.jna.platform.win32.WinDef.WORDByReference)2 Dispatch (com.sun.jna.platform.win32.COM.Dispatch)1 IEnumMoniker (com.sun.jna.platform.win32.COM.IEnumMoniker)1 Moniker (com.sun.jna.platform.win32.COM.Moniker)1 DATE (com.sun.jna.platform.win32.OaIdl.DATE)1 VARIANT_BOOL (com.sun.jna.platform.win32.OaIdl.VARIANT_BOOL)1 VARIANT (com.sun.jna.platform.win32.Variant.VARIANT)1 BSTR (com.sun.jna.platform.win32.WTypes.BSTR)1 BOOL (com.sun.jna.platform.win32.WinDef.BOOL)1 BYTE (com.sun.jna.platform.win32.WinDef.BYTE)1 CHAR (com.sun.jna.platform.win32.WinDef.CHAR)1 LONG (com.sun.jna.platform.win32.WinDef.LONG)1 LONGLONG (com.sun.jna.platform.win32.WinDef.LONGLONG)1 SHORT (com.sun.jna.platform.win32.WinDef.SHORT)1 USHORT (com.sun.jna.platform.win32.WinDef.USHORT)1