use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class TypeInfoUtil method GetContainingTypeLib.
/**
* Gets the containing type lib.
*
* @return the containing type lib
*/
public ContainingTypeLib GetContainingTypeLib() {
PointerByReference ppTLib = new PointerByReference();
UINTByReference pIndex = new UINTByReference();
HRESULT hr = this.typeInfo.GetContainingTypeLib(ppTLib, pIndex);
COMUtils.checkRC(hr);
return new ContainingTypeLib(new TypeLib(ppTLib.getValue()), pIndex.getValue().intValue());
}
use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class TypeInfoUtil method getTypeComp.
/**
* Gets the type comp.
*
* @return the type comp
*/
public TypeComp getTypeComp() {
PointerByReference ppTypeAttr = new PointerByReference();
HRESULT hr = this.typeInfo.GetTypeComp(ppTypeAttr);
COMUtils.checkRC(hr);
return new TypeComp(ppTypeAttr.getValue());
}
use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class Crypt32Test method testCryptProtectUnprotectData.
public void testCryptProtectUnprotectData() {
DATA_BLOB pDataIn = new DATA_BLOB("hello world");
DATA_BLOB pDataEncrypted = new DATA_BLOB();
try {
assertTrue("CryptProtectData(Initial)", Crypt32.INSTANCE.CryptProtectData(pDataIn, "description", null, null, null, 0, pDataEncrypted));
PointerByReference pDescription = new PointerByReference();
try {
DATA_BLOB pDataDecrypted = new DATA_BLOB();
try {
assertTrue("CryptProtectData(Crypt)", Crypt32.INSTANCE.CryptUnprotectData(pDataEncrypted, pDescription, null, null, null, 0, pDataDecrypted));
assertEquals("description", pDescription.getValue().getWideString(0));
assertEquals("hello world", pDataDecrypted.pbData.getString(0));
} finally {
Kernel32Util.freeLocalMemory(pDataDecrypted.pbData);
}
} finally {
Kernel32Util.freeLocalMemory(pDescription.getValue());
}
} finally {
Kernel32Util.freeLocalMemory(pDataEncrypted.pbData);
}
}
use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class HybdridCOMInvocationTest method testOfficeInvocationDemonstration.
public void testOfficeInvocationDemonstration() {
// THIS IS NOT A TEST
//
// This reproduces the problem by using the dispatch directly.
PointerByReference pDispatch = new PointerByReference();
HRESULT hr = Ole32.INSTANCE.CoCreateInstance(CLSID_WORD, null, WTypes.CLSCTX_SERVER, IID_APPLICATION, pDispatch);
if (!COMUtils.SUCCEEDED(hr)) {
LOG.log(Level.INFO, "HybdridCOMInvocationTest test was not run, MS Word object could not be instantiated.");
return;
}
Dispatch dp = new Dispatch(pDispatch.getValue());
// DispID of InchesToPoints
DISPID dispId = new OaIdl.DISPID(0x00000172);
// Interface _Application of MS Word type library
WinDef.LCID LOCALE_SYSTEM_DEFAULT = Kernel32.INSTANCE.GetSystemDefaultLCID();
Variant.VARIANT.ByReference result = new Variant.VARIANT.ByReference();
OaIdl.EXCEPINFO.ByReference pExcepInfo = new OaIdl.EXCEPINFO.ByReference();
IntByReference puArgErr = new IntByReference();
WORD wFlagsMethod = new WinDef.WORD(OleAuto.DISPATCH_METHOD);
WORD wFlagsGet = new WinDef.WORD(OleAuto.DISPATCH_PROPERTYGET);
WORD wFlagsCombined = new WinDef.WORD(OleAuto.DISPATCH_METHOD | OleAuto.DISPATCH_PROPERTYGET);
OleAuto.DISPPARAMS.ByReference pDispParams = new OleAuto.DISPPARAMS.ByReference();
VARIANT[] params = new VARIANT[] { new VARIANT(1f) };
pDispParams.setArgs(params);
// Call InchesToPoints as a method
hr = dp.Invoke(dispId, new REFIID(Guid.IID_NULL), LOCALE_SYSTEM_DEFAULT, wFlagsMethod, pDispParams, result, pExcepInfo, puArgErr);
assertTrue(COMUtils.FAILED(hr));
// Call InchesToPoints as a property getter
hr = dp.Invoke(dispId, new REFIID(Guid.IID_NULL), LOCALE_SYSTEM_DEFAULT, wFlagsGet, pDispParams, result, pExcepInfo, puArgErr);
assertTrue(COMUtils.FAILED(hr));
// Call InchesToPoints as a hybrid
hr = dp.Invoke(dispId, new REFIID(Guid.IID_NULL), LOCALE_SYSTEM_DEFAULT, wFlagsCombined, pDispParams, result, pExcepInfo, puArgErr);
assertTrue(COMUtils.SUCCEEDED(hr));
assertEquals(72.0f, result.floatValue());
}
use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class Netapi32Test method testNetUserEnum.
public void testNetUserEnum() {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesread = new IntByReference();
IntByReference totalentries = new IntByReference();
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserEnum(null, 1, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries, null));
USER_INFO_1 userinfo = new USER_INFO_1(bufptr.getValue());
USER_INFO_1[] userinfos = (USER_INFO_1[]) userinfo.toArray(entriesread.getValue());
for (USER_INFO_1 ui : userinfos) {
assertTrue(ui.usri1_name.length() > 0);
}
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
}
Aggregations