Search in sources :

Example 1 with MEMBERID

use of com.sun.jna.platform.win32.OaIdl.MEMBERID 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 MEMBERID

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

the class ITypeLibTest method testFindName.

public void testFindName() {
    ITypeLib shellTypeLib = loadShellTypeLib();
    // The found member is Count, search done with lowercase value to test
    // correct behaviour (search is case insensitive)
    String memberValue = "count";
    String memberValueOk = "Count";
    Pointer p = Ole32.INSTANCE.CoTaskMemAlloc((memberValue.length() + 1L) * Native.WCHAR_SIZE);
    WTypes.LPOLESTR olestr = new WTypes.LPOLESTR(p);
    olestr.setValue(memberValue);
    short maxResults = 100;
    ULONG lHashVal = new ULONG(0);
    USHORTByReference pcFound = new USHORTByReference(maxResults);
    Pointer[] pointers = new Pointer[maxResults];
    MEMBERID[] rgMemId = new MEMBERID[maxResults];
    HRESULT hr = shellTypeLib.FindName(olestr, lHashVal, pointers, rgMemId, pcFound);
    assertTrue(COMUtils.SUCCEEDED(hr));
    // If a reader can come up with more tests it would be appretiated,
    // the documentation is unclear what more can be expected
    // 2 matches come from manual tests
    assertTrue(pcFound.getValue().intValue() == 2);
    // Check that function return corrected member name (Count) - see uppercase C
    assertEquals(memberValueOk, olestr.getValue());
    // There have to be as many pointers as reported by pcFound
    assertNotNull(pointers[0]);
    assertNotNull(pointers[1]);
    // Might be flaky, contract only defined positions 0 -> (pcFound - 1)
    assertNull(pointers[2]);
    // Test access to second value
    TypeInfo secondTypeInfo = new TypeInfo(pointers[1]);
    PointerByReference pbr = new PointerByReference();
    hr = secondTypeInfo.GetTypeAttr(pbr);
    assertTrue(COMUtils.SUCCEEDED(hr));
    OaIdl.TYPEATTR pTypeAttr = new OaIdl.TYPEATTR(pbr.getValue());
    // Either interface FolderItemVerbs ({1F8352C0-50B0-11CF-960C-0080C7F4EE85})
    // or FolderItems ({744129E0-CBE5-11CE-8350-444553540000})
    String typeGUID = pTypeAttr.guid.toGuidString();
    assertTrue(typeGUID.equals("{1F8352C0-50B0-11CF-960C-0080C7F4EE85}") || typeGUID.equals("{744129E0-CBE5-11CE-8350-444553540000}"));
    secondTypeInfo.ReleaseTypeAttr(pTypeAttr);
    Ole32.INSTANCE.CoTaskMemFree(olestr.getPointer());
}
Also used : ULONG(com.sun.jna.platform.win32.WinDef.ULONG) HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) MEMBERID(com.sun.jna.platform.win32.OaIdl.MEMBERID) Pointer(com.sun.jna.Pointer) WString(com.sun.jna.WString) WTypes(com.sun.jna.platform.win32.WTypes) PointerByReference(com.sun.jna.ptr.PointerByReference) USHORTByReference(com.sun.jna.platform.win32.WinDef.USHORTByReference) OaIdl(com.sun.jna.platform.win32.OaIdl)

Example 3 with MEMBERID

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

the class TypeLibUtilTest method testGetTypeInfo.

public void testGetTypeInfo() {
    TypeLibUtil shellTypeLib = loadShellTypeLib();
    int typeInfoCount = shellTypeLib.getTypeInfoCount();
    for (int i = 0; i < typeInfoCount; i++) {
        ITypeInfo typeInfo = shellTypeLib.getTypeInfo(i);
        TypeInfoUtil typeInfoUtil = new TypeInfoUtil(typeInfo);
        TYPEATTR typeAttr = typeInfoUtil.getTypeAttr();
        int cFuncs = typeAttr.cFuncs.intValue();
        for (int y = 0; y < cFuncs; y++) {
            // Get the function description
            FUNCDESC funcDesc = typeInfoUtil.getFuncDesc(y);
            // Get the member ID
            MEMBERID memberID = funcDesc.memid;
            // Get the name of the method
            TypeInfoDoc typeInfoDoc2 = typeInfoUtil.getDocumentation(memberID);
            String methodName = typeInfoDoc2.getName();
            assertNotNull(methodName);
            typeInfoUtil.ReleaseFuncDesc(funcDesc);
        }
        typeInfoUtil.ReleaseTypeAttr(typeAttr);
    }
}
Also used : MEMBERID(com.sun.jna.platform.win32.OaIdl.MEMBERID) TypeInfoDoc(com.sun.jna.platform.win32.COM.TypeInfoUtil.TypeInfoDoc) TYPEATTR(com.sun.jna.platform.win32.OaIdl.TYPEATTR) FUNCDESC(com.sun.jna.platform.win32.OaIdl.FUNCDESC)

Example 4 with MEMBERID

use of com.sun.jna.platform.win32.OaIdl.MEMBERID 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 5 with MEMBERID

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

the class TypeInfoUtil method AddressOfMember.

/**
     * Address of member.
     * 
     * @param memid
     *            the memid
     * @param invKind
     *            the inv kind
     * @return the pointer by reference
     */
public PointerByReference AddressOfMember(MEMBERID memid, INVOKEKIND invKind) {
    PointerByReference ppv = new PointerByReference();
    HRESULT hr = this.typeInfo.AddressOfMember(memid, invKind, ppv);
    COMUtils.checkRC(hr);
    return ppv;
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) PointerByReference(com.sun.jna.ptr.PointerByReference)

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