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());
}
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");
}
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());
}
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");
}
};
}
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;
}
Aggregations