use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class Netapi32Test method testNetGetJoinInformation.
public void testNetGetJoinInformation() {
IntByReference bufferType = new IntByReference();
assertEquals(W32Errors.ERROR_INVALID_PARAMETER, Netapi32.INSTANCE.NetGetJoinInformation(null, null, bufferType));
PointerByReference lpNameBuffer = new PointerByReference();
assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetGetJoinInformation(null, lpNameBuffer, bufferType));
assertTrue(lpNameBuffer.getValue().getString(0).length() > 0);
assertTrue(bufferType.getValue() > 0);
assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue()));
}
use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class Netapi32Test method testNetUserGetLocalGroups.
public void testNetUserGetLocalGroups() {
String currentUser = Secur32Util.getUserNameEx(EXTENDED_NAME_FORMAT.NameSamCompatible);
PointerByReference bufptr = new PointerByReference();
IntByReference entriesread = new IntByReference();
IntByReference totalentries = new IntByReference();
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserGetLocalGroups(null, currentUser, 0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries));
LOCALGROUP_USERS_INFO_0 lgroup = new LOCALGROUP_USERS_INFO_0(bufptr.getValue());
LOCALGROUP_USERS_INFO_0[] lgroups = (LOCALGROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
for (LOCALGROUP_USERS_INFO_0 localGroupInfo : lgroups) {
assertTrue(localGroupInfo.lgrui0_name.length() > 0);
}
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
}
use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class Netapi32Test method testNetGroupEnum.
public void testNetGroupEnum() {
PointerByReference bufptr = new PointerByReference();
IntByReference entriesread = new IntByReference();
IntByReference totalentries = new IntByReference();
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetGroupEnum(null, 2, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries, null));
GROUP_INFO_2 group = new GROUP_INFO_2(bufptr.getValue());
GROUP_INFO_2[] groups = (GROUP_INFO_2[]) group.toArray(entriesread.getValue());
for (GROUP_INFO_2 grpi : groups) {
assertTrue(grpi.grpi2_name.length() > 0);
}
assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
}
use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class ObjectFactory method fetchObject.
/**
* Gets and existing COM object (GetActiveObject) for the given progId and
* returns a ProxyObject for the given interface.
*/
public <T> T fetchObject(Class<T> comInterface) {
assert COMUtils.comIsInitialized() : "COM not initialized";
ComObject comObectAnnotation = comInterface.getAnnotation(ComObject.class);
if (null == comObectAnnotation) {
throw new COMException("createObject: Interface must define a value for either clsId or progId via the ComInterface annotation");
}
final GUID guid = this.discoverClsId(comObectAnnotation);
final PointerByReference ptrDisp = new PointerByReference();
WinNT.HRESULT hr = OleAuto.INSTANCE.GetActiveObject(guid, null, ptrDisp);
COMUtils.checkRC(hr);
Dispatch d = new Dispatch(ptrDisp.getValue());
T t = this.createProxy(comInterface, d);
//GetActiveObject returns a pointer to COM object with a +1 reference count, so we must drop one
//Note: the createProxy adds one
d.Release();
return t;
}
use of com.sun.jna.ptr.PointerByReference in project jna by java-native-access.
the class ProxyObject method fetchRawConnectionPoint.
// ---------------------- IConnectionPoint ----------------------
private ConnectionPoint fetchRawConnectionPoint(IID iid) throws InterruptedException, ExecutionException, TimeoutException {
assert COMUtils.comIsInitialized() : "COM not initialized";
// query for ConnectionPointContainer
IConnectionPointContainer cpc = this.queryInterface(IConnectionPointContainer.class);
Dispatch rawCpcDispatch = (Dispatch) cpc.getRawDispatch();
final ConnectionPointContainer rawCpc = new ConnectionPointContainer(rawCpcDispatch.getPointer());
// find connection point for comEventCallback interface
final REFIID adviseRiid = new REFIID(iid.getPointer());
final PointerByReference ppCp = new PointerByReference();
HRESULT hr = rawCpc.FindConnectionPoint(adviseRiid, ppCp);
COMUtils.checkRC(hr);
final ConnectionPoint rawCp = new ConnectionPoint(ppCp.getValue());
return rawCp;
}
Aggregations