use of com.sun.jna.ptr.IntByReference in project jna by java-native-access.
the class ITypeInfoTest method testGetImplTypeFlags.
@Test
public void testGetImplTypeFlags() {
ITypeInfo typeInfo = getTypeInfo();
IntByReference pImplTypeFlags = new IntByReference();
HRESULT hr = typeInfo.GetImplTypeFlags(new UINT(0), pImplTypeFlags);
COMUtils.checkRC(hr);
assertEquals(0, hr.intValue());
//System.out.println("GetImplTypeFlags: " + pImplTypeFlags.toString());
}
use of com.sun.jna.ptr.IntByReference in project jna by java-native-access.
the class Advapi32Test method testSetGetSecurityDescriptorGroup.
public void testSetGetSecurityDescriptorGroup() {
SECURITY_DESCRIPTOR sd = new SECURITY_DESCRIPTOR(64 * 1024);
assertTrue(Advapi32.INSTANCE.InitializeSecurityDescriptor(sd, WinNT.SECURITY_DESCRIPTOR_REVISION));
PSID pSidPut = new PSID(WinNT.SECURITY_MAX_SID_SIZE);
IntByReference cbSid = new IntByReference(WinNT.SECURITY_MAX_SID_SIZE);
assertTrue("Failed to create well-known SID", Advapi32.INSTANCE.CreateWellKnownSid(WELL_KNOWN_SID_TYPE.WinBuiltinAdministratorsSid, null, pSidPut, cbSid));
assertTrue(Advapi32.INSTANCE.SetSecurityDescriptorGroup(sd, pSidPut, true));
BOOLByReference lpbOwnerDefaulted = new BOOLByReference();
PSIDByReference prSd = new PSIDByReference();
assertTrue(Advapi32.INSTANCE.GetSecurityDescriptorGroup(sd, prSd, lpbOwnerDefaulted));
PSID pSidGet = prSd.getValue();
assertTrue(Advapi32.INSTANCE.EqualSid(pSidPut, pSidGet));
}
use of com.sun.jna.ptr.IntByReference in project jna by java-native-access.
the class Advapi32Test method testReadEventLog.
public void testReadEventLog() {
HANDLE h = Advapi32.INSTANCE.OpenEventLog(null, "Application");
IntByReference pnBytesRead = new IntByReference();
IntByReference pnMinNumberOfBytesNeeded = new IntByReference();
Memory buffer = new Memory(1);
assertFalse(Advapi32.INSTANCE.ReadEventLog(h, WinNT.EVENTLOG_SEQUENTIAL_READ | WinNT.EVENTLOG_BACKWARDS_READ, 0, buffer, (int) buffer.size(), pnBytesRead, pnMinNumberOfBytesNeeded));
assertEquals(W32Errors.ERROR_INSUFFICIENT_BUFFER, Kernel32.INSTANCE.GetLastError());
assertTrue(pnMinNumberOfBytesNeeded.getValue() > 0);
assertTrue(Advapi32.INSTANCE.CloseEventLog(h));
}
use of com.sun.jna.ptr.IntByReference in project jna by java-native-access.
the class Advapi32Test method testGetSetFileSecurityNoSACL.
public void testGetSetFileSecurityNoSACL() throws Exception {
int infoType = OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION;
int memSize = 64 * 1024;
Memory memorySecurity = new Memory(memSize);
IntByReference sizeNeeded = new IntByReference(0);
// create a temp file
File file = createTempFile();
String filePath = file.getAbsolutePath();
try {
assertEquals("GetFileSecurity(" + filePath + ")", true, Advapi32.INSTANCE.GetFileSecurity(filePath, infoType, memorySecurity, memSize, sizeNeeded));
assertEquals("SetFileSecurity(" + filePath + ")", true, Advapi32.INSTANCE.SetFileSecurity(filePath, infoType, memorySecurity));
} finally {
file.delete();
}
}
use of com.sun.jna.ptr.IntByReference in project jmonkeyengine by jMonkeyEngine.
the class OpenVRUtil method getTrackedDeviceStringProperty.
/**
* Get the value of the given string {@link JOpenVRLibrary.ETrackedDeviceProperty property} attached to the given device.
* @param system the underlying OpenVR system.
* @param deviceIndex the index of the device to query.
* @param property the property to query.
* @param bufferSize the size of the buffer to use for storing native string.
* @return the value of the given string property attached to the given device.
* @see OpenVRInput#getTrackedControllerCount()
* @see JOpenVRLibrary.ETrackedDeviceProperty
* @see #getTrackedDeviceStringProperty(VR_IVRSystem_FnTable, int, int)
*/
public static String getTrackedDeviceStringProperty(VR_IVRSystem_FnTable system, int deviceIndex, int property, int bufferSize) {
String str = "";
int unBufferSize = 256;
Pointer pchValue = new Memory(unBufferSize);
IntByReference pError = new IntByReference();
system.GetStringTrackedDeviceProperty.apply(deviceIndex, property, pchValue, unBufferSize, pError);
if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_Success) {
str = pchValue.getString(0);
} else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_BufferTooSmall) {
throw new IllegalArgumentException("Cannot access property \"" + getETrackedDevicePropertyString(property) + "\" (" + property + ") for device " + deviceIndex + ": " + getETrackedPropertyErrorString(pError.getValue()) + " (" + pError.getValue() + ")");
} else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_CouldNotContactServer) {
throw new IllegalArgumentException("Cannot access property \"" + getETrackedDevicePropertyString(property) + "\" (" + property + ") for device " + deviceIndex + ": " + getETrackedPropertyErrorString(pError.getValue()) + " (" + pError.getValue() + ")");
} else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidDevice) {
throw new IllegalArgumentException("Cannot access property \"" + getETrackedDevicePropertyString(property) + "\" (" + property + ") for device " + deviceIndex + ": " + getETrackedPropertyErrorString(pError.getValue()) + " (" + pError.getValue() + ")");
} else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidOperation) {
throw new IllegalArgumentException("Cannot access property \"" + getETrackedDevicePropertyString(property) + "\" (" + property + ") for device " + deviceIndex + ": " + getETrackedPropertyErrorString(pError.getValue()) + " (" + pError.getValue() + ")");
} else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_NotYetAvailable) {
throw new IllegalArgumentException("Cannot access property \"" + getETrackedDevicePropertyString(property) + "\" (" + property + ") for device " + deviceIndex + ": " + getETrackedPropertyErrorString(pError.getValue()) + " (" + pError.getValue() + ")");
} else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_PermissionDenied) {
throw new IllegalArgumentException("Cannot access property \"" + getETrackedDevicePropertyString(property) + "\" (" + property + ") for device " + deviceIndex + ": " + getETrackedPropertyErrorString(pError.getValue()) + " (" + pError.getValue() + ")");
} else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_StringExceedsMaximumLength) {
throw new IllegalArgumentException("Cannot access property \"" + getETrackedDevicePropertyString(property) + "\" (" + property + ") for device " + deviceIndex + ": " + getETrackedPropertyErrorString(pError.getValue()) + " (" + pError.getValue() + ")");
} else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_UnknownProperty) {
throw new IllegalArgumentException("Cannot access property \"" + getETrackedDevicePropertyString(property) + "\" (" + property + ") for device " + deviceIndex + ": " + getETrackedPropertyErrorString(pError.getValue()) + " (" + pError.getValue() + ")");
} else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_ValueNotProvidedByDevice) {
throw new IllegalArgumentException("Cannot access property \"" + getETrackedDevicePropertyString(property) + "\" (" + property + ") for device " + deviceIndex + ": " + getETrackedPropertyErrorString(pError.getValue()) + " (" + pError.getValue() + ")");
} else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDataType) {
throw new IllegalArgumentException("Cannot access property \"" + getETrackedDevicePropertyString(property) + "\" (" + property + ") for device " + deviceIndex + ": " + getETrackedPropertyErrorString(pError.getValue()) + " (" + pError.getValue() + ")");
} else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDeviceClass) {
throw new IllegalArgumentException("Cannot access property \"" + getETrackedDevicePropertyString(property) + "\" (" + property + ") for device " + deviceIndex + ": " + getETrackedPropertyErrorString(pError.getValue()) + " (" + pError.getValue() + ")");
} else {
throw new IllegalArgumentException("Cannot access property \"" + getETrackedDevicePropertyString(property) + "\" (" + property + ") for device " + deviceIndex + ": " + getETrackedPropertyErrorString(pError.getValue()) + " (" + pError.getValue() + ")");
}
return str;
}
Aggregations