Search in sources :

Example 11 with MEMBERID

use of com.sun.jna.platform.win32.OaIdl.MEMBERID in project jna by java-native-access.

the class TypeInfoUtil method getIDsOfNames.

/**
     * Gets the i ds of names.
     * 
     * @param rgszNames
     *            the rgsz names
     * @param cNames
     *            the c names
     * @return the i ds of names
     */
public MEMBERID[] getIDsOfNames(LPOLESTR[] rgszNames, int cNames) {
    MEMBERID[] pMemId = new MEMBERID[cNames];
    HRESULT hr = this.typeInfo.GetIDsOfNames(rgszNames, new UINT(cNames), pMemId);
    COMUtils.checkRC(hr);
    return pMemId;
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) MEMBERID(com.sun.jna.platform.win32.OaIdl.MEMBERID) UINT(com.sun.jna.platform.win32.WinDef.UINT)

Example 12 with MEMBERID

use of com.sun.jna.platform.win32.OaIdl.MEMBERID in project jna by java-native-access.

the class TypeInfoUtil method getNames.

/**
     * Gets the names.
     * 
     * @param memid
     *            the memid
     * @param maxNames
     *            the max names
     * @return the names
     */
public String[] getNames(MEMBERID memid, int maxNames) {
    BSTR[] rgBstrNames = new BSTR[maxNames];
    UINTByReference pcNames = new UINTByReference();
    HRESULT hr = this.typeInfo.GetNames(memid, rgBstrNames, new UINT(maxNames), pcNames);
    COMUtils.checkRC(hr);
    int cNames = pcNames.getValue().intValue();
    String[] result = new String[cNames];
    for (int i = 0; i < result.length; i++) {
        result[i] = rgBstrNames[i].getValue();
        OLEAUTO.SysFreeString(rgBstrNames[i]);
    }
    return result;
}
Also used : BSTR(com.sun.jna.platform.win32.WTypes.BSTR) UINTByReference(com.sun.jna.platform.win32.WinDef.UINTByReference) HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) UINT(com.sun.jna.platform.win32.WinDef.UINT)

Example 13 with MEMBERID

use of com.sun.jna.platform.win32.OaIdl.MEMBERID in project jna by java-native-access.

the class ITypeInfoTest method testAddressOfMember.

@Test
@Ignore("Needs a DLL that contains code")
public void testAddressOfMember() {
    ITypeInfo[] typeInfos = getTypeInfos();
    MEMBERID memid = new MEMBERID();
    PointerByReference ppv = new PointerByReference();
    for (ITypeInfo typeInfo : typeInfos) {
        HRESULT hr = typeInfo.AddressOfMember(memid, INVOKEKIND.INVOKE_FUNC, ppv);
        if (COMUtils.SUCCEEDED(hr)) {
            //System.out.println("AddressOfMember: " + ppv.toString());
            return;
        }
    }
    throw new RuntimeException("Didn't find address for function in any of the type infos");
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) MEMBERID(com.sun.jna.platform.win32.OaIdl.MEMBERID) PointerByReference(com.sun.jna.ptr.PointerByReference) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 14 with MEMBERID

use of com.sun.jna.platform.win32.OaIdl.MEMBERID in project jna by java-native-access.

the class ITypeInfoTest method testGetNames.

@Test
public void testGetNames() {
    ITypeInfo[] typeInfos = getTypeInfos();
    MEMBERID memid = new MEMBERID(1);
    BSTR[] rgBstrNames = new BSTR[1];
    UINT cMaxNames = new UINT(1);
    UINTByReference pcNames = new UINTByReference();
    for (ITypeInfo typeInfo : typeInfos) {
        HRESULT hr = typeInfo.GetNames(memid, rgBstrNames, cMaxNames, pcNames);
        if (COMUtils.SUCCEEDED(hr)) {
            //System.out.println("pcNames: " + pcNames.getValue().intValue());
            return;
        }
    }
    throw new RuntimeException("Didn't find name for member in any of the type infos");
}
Also used : BSTR(com.sun.jna.platform.win32.WTypes.BSTR) UINTByReference(com.sun.jna.platform.win32.WinDef.UINTByReference) HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) MEMBERID(com.sun.jna.platform.win32.OaIdl.MEMBERID) UINT(com.sun.jna.platform.win32.WinDef.UINT) Test(org.junit.Test)

Example 15 with MEMBERID

use of com.sun.jna.platform.win32.OaIdl.MEMBERID in project jna by java-native-access.

the class COMTest method testTYPEATTR.

public void testTYPEATTR() {
    int pSize = Native.POINTER_SIZE;
    TYPEATTR typeAttr = new TYPEATTR();
    typeAttr.guid = GUID.fromString("{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}");
    typeAttr.lcid = Kernel32.INSTANCE.GetSystemDefaultLCID();
    typeAttr.dwReserved = new DWORD(1);
    typeAttr.memidConstructor = new MEMBERID(2);
    typeAttr.memidDestructor = new MEMBERID(3);
    typeAttr.lpstrSchema = new LPOLESTR("Hello World");
    typeAttr.cbSizeInstance = new ULONG(4);
    typeAttr.typekind = new TYPEKIND(5);
    typeAttr.cFuncs = new WORD(6);
    typeAttr.cVars = new WORD(7);
    typeAttr.cImplTypes = new WORD(8);
    typeAttr.cbSizeVft = new WORD(9);
    typeAttr.cbAlignment = new WORD(10);
    typeAttr.wMajorVerNum = new WORD(11);
    typeAttr.wMinorVerNum = new WORD(12);
    typeAttr.tdescAlias = new TYPEDESC();
    typeAttr.idldescType = new IDLDESC();
    typeAttr.write();
    typeAttr.read();
//System.out.println(typeAttr.toString());
//System.out.println("TYPEATTR size: " + typeAttr.size());
}
Also used : ULONG(com.sun.jna.platform.win32.WinDef.ULONG) DWORD(com.sun.jna.platform.win32.WinDef.DWORD) WORD(com.sun.jna.platform.win32.WinDef.WORD) MEMBERID(com.sun.jna.platform.win32.OaIdl.MEMBERID) TYPEDESC(com.sun.jna.platform.win32.OaIdl.TYPEDESC) TYPEATTR(com.sun.jna.platform.win32.OaIdl.TYPEATTR) LPOLESTR(com.sun.jna.platform.win32.WTypes.LPOLESTR) DWORD(com.sun.jna.platform.win32.WinDef.DWORD) IDLDESC(com.sun.jna.platform.win32.OaIdl.IDLDESC) TYPEKIND(com.sun.jna.platform.win32.OaIdl.TYPEKIND)

Aggregations

HRESULT (com.sun.jna.platform.win32.WinNT.HRESULT)15 MEMBERID (com.sun.jna.platform.win32.OaIdl.MEMBERID)11 BSTRByReference (com.sun.jna.platform.win32.WTypes.BSTRByReference)7 Test (org.junit.Test)6 DWORDByReference (com.sun.jna.platform.win32.WinDef.DWORDByReference)5 UINT (com.sun.jna.platform.win32.WinDef.UINT)4 PointerByReference (com.sun.jna.ptr.PointerByReference)4 LPOLESTR (com.sun.jna.platform.win32.WTypes.LPOLESTR)3 UINTByReference (com.sun.jna.platform.win32.WinDef.UINTByReference)3 ULONG (com.sun.jna.platform.win32.WinDef.ULONG)3 WORDByReference (com.sun.jna.platform.win32.WinDef.WORDByReference)3 Pointer (com.sun.jna.Pointer)2 TYPEATTR (com.sun.jna.platform.win32.OaIdl.TYPEATTR)2 WTypes (com.sun.jna.platform.win32.WTypes)2 BSTR (com.sun.jna.platform.win32.WTypes.BSTR)2 USHORTByReference (com.sun.jna.platform.win32.WinDef.USHORTByReference)2 Ignore (org.junit.Ignore)2 WString (com.sun.jna.WString)1 TypeInfoDoc (com.sun.jna.platform.win32.COM.TypeInfoUtil.TypeInfoDoc)1 OaIdl (com.sun.jna.platform.win32.OaIdl)1