Java Code Examples for com.sun.jna.ptr.IntByReference#getValue()

The following examples show how to use com.sun.jna.ptr.IntByReference#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotesACL.java    From domino-jna with Apache License 2.0 6 votes vote down vote up
/**
 * Check if "Enforce consistent ACL" is set
 * 
 * @return true if set
 */
public boolean isUniformAccess() {
	checkHandle();
	
	IntByReference retFlags = new IntByReference();
	
	short result;
	if (PlatformUtils.is64Bit()) {
		result = NotesNativeAPI64.get().ACLGetFlags(m_hACL64, retFlags);
	}
	else {
		result = NotesNativeAPI64.get().ACLGetFlags(m_hACL64, retFlags);
	}
	NotesErrorUtils.checkResult(result);
	
	return (retFlags.getValue() & NotesConstants.ACL_UNIFORM_ACCESS) == NotesConstants.ACL_UNIFORM_ACCESS;
}
 
Example 2
Source File: Kernel32Utils.java    From libreveris with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Given the process handle, waits for its completion and returns the exit
 * code.
 */
public static int waitForExitProcess (Pointer hProcess)
        throws InterruptedException
{
    while (true) {
        if (Thread.interrupted()) {
            throw new InterruptedException();
        }

        Kernel32.INSTANCE.WaitForSingleObject(hProcess, 1000);

        IntByReference exitCode = new IntByReference();
        exitCode.setValue(-1);
        Kernel32.INSTANCE.GetExitCodeProcess(hProcess, exitCode);

        int v = exitCode.getValue();

        if (v != Kernel32.STILL_ACTIVE) {
            return v;
        }
    }
}
 
Example 3
Source File: NotesCollection.java    From domino-jna with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the total number of documents in the view
 * 
 * @return document count
 */
public int getDocumentCount() {
	checkHandle();
	
	IntByReference retDocCount = new IntByReference();
	short result;
	//use lightweight function that reads the count from the note id index (fast)
	if (PlatformUtils.is64Bit()) {
		result = NotesNativeAPI64.get().NIFGetCollectionDocCountLW(m_hCollection64, retDocCount);
	}
	else {
		result = NotesNativeAPI32.get().NIFGetCollectionDocCountLW(m_hCollection32, retDocCount);
	}
	NotesErrorUtils.checkResult(result);
	
	return retDocCount.getValue();
}
 
Example 4
Source File: NotesCollection.java    From domino-jna with Apache License 2.0 6 votes vote down vote up
/**
 * Method to check if a note is visible in a view for the current user
 * 
 * @param noteId note id
 * @return true if visible
 */
public boolean isNoteInView(int noteId) {
	checkHandle();
	
	short result;
	
	IntByReference retIsInView = new IntByReference();
	if (PlatformUtils.is64Bit()) {
		result = NotesNativeAPI64.get().NIFIsNoteInView(m_hCollection64, noteId, retIsInView);
	}
	else {
		result = NotesNativeAPI32.get().NIFIsNoteInView(m_hCollection32, noteId, retIsInView);
	}
	NotesErrorUtils.checkResult(result);
	boolean isInView = retIsInView.getValue()==1;
	return isInView;
}
 
Example 5
Source File: Nc4Iosp.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private boolean nc_inq_var(Formatter f, int grpid, int varno) throws IOException {
  byte[] name = new byte[Nc4prototypes.NC_MAX_NAME + 1];
  IntByReference xtypep = new IntByReference();
  IntByReference ndimsp = new IntByReference();
  int[] dimids = new int[Nc4prototypes.NC_MAX_DIMS];
  IntByReference nattsp = new IntByReference();

  int ret = nc4.nc_inq_var(grpid, varno, name, xtypep, ndimsp, dimids, nattsp);
  if (ret != 0)
    return false;

  String vname = makeString(name);
  int typeid = xtypep.getValue();
  ConvertedType cvt = convertDataType(typeid);

  for (int i = 0; i < ndimsp.getValue(); i++) {
    f.format("%d ", dimids[i]);
  }

  String dimList = makeDimList(grpid, ndimsp.getValue(), dimids);

  f.format(") dims=(%s)%n", dimList);
  return true;
}
 
Example 6
Source File: Advapi32Util.java    From jpexs-decompiler with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get names of the registry key's sub-keys.
 *
 * @param hKey Registry key.
 * @return Array of registry key names.
 */
public static String[] registryGetKeys(HKEY hKey) {
    IntByReference lpcSubKeys = new IntByReference();
    IntByReference lpcMaxSubKeyLen = new IntByReference();
    int rc = Advapi32.INSTANCE.RegQueryInfoKey(hKey, null, null, null,
            lpcSubKeys, lpcMaxSubKeyLen, null, null, null, null, null, null);
    if (rc != W32Errors.ERROR_SUCCESS) {
        throw new Win32Exception(rc);
    }
    ArrayList<String> keys = new ArrayList<>(lpcSubKeys.getValue());
    char[] name = new char[lpcMaxSubKeyLen.getValue() + 1];
    for (int i = 0; i < lpcSubKeys.getValue(); i++) {
        IntByReference lpcchValueName = new IntByReference(lpcMaxSubKeyLen.getValue() + 1);
        rc = Advapi32.INSTANCE.RegEnumKeyEx(hKey, i, name, lpcchValueName,
                null, null, null, null);
        if (rc != W32Errors.ERROR_SUCCESS) {
            throw new Win32Exception(rc);
        }
        keys.add(Native.toString(name));
    }
    return keys.toArray(new String[keys.size()]);
}
 
Example 7
Source File: WdmDll.java    From OpenDA with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void putValues(int wdmFileNumber, int dataSetNumber, int timeStep, int[] startDate,
        int overwriteData, int qualityCode, int timeUnit, double[] values) {

    IntByReference numberOfValues = new IntByReference(values.length);
    IntByReference returnCode = new IntByReference(-1);
    nativeDLL.wdtput_(new IntByReference(wdmFileNumber), new IntByReference(dataSetNumber),
            new IntByReference(timeStep), startDate, numberOfValues,
            new IntByReference(overwriteData), new IntByReference(qualityCode),
            new IntByReference(timeUnit), BBUtils.toFloatArray(values), returnCode);
    if (returnCode.getValue() != 0) {
        throw new RuntimeException("WdmDll: Invalid result from call to subroutine dll.wdtput_ , returnCode = " + returnCode.getValue());
    }
}
 
Example 8
Source File: WindowsConsoleInputStream.java    From lanterna with GNU Lesser General Public License v3.0 5 votes vote down vote up
private int availableConsoleInput() {
	IntByReference lpcNumberOfEvents = new IntByReference();
	if (Wincon.INSTANCE.GetNumberOfConsoleInputEvents(hConsoleInput, lpcNumberOfEvents)) {
		return lpcNumberOfEvents.getValue();
	}
	return 0;
}
 
Example 9
Source File: WdmDll.java    From OpenDA with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void deleteValues(int wdmFileNumber, int dataSetNumber, int[] deleteFromDate, int deleteAll) {
    IntByReference returnCode = new IntByReference(-1);
    nativeDLL.wtddel_(new IntByReference(wdmFileNumber), new IntByReference(dataSetNumber),
            deleteFromDate, new IntByReference(deleteAll), returnCode);
    if (returnCode.getValue() != 0) {
        throw new RuntimeException("WdmDll: Invalid result from call to subroutine dll.wtddel_ , returnCode = " + returnCode.getValue());
    }
}
 
Example 10
Source File: Advapi32Util.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get a registry REG_MULTI_SZ value.
 *
 * @param root Root key.
 * @param key Registry path.
 * @param value Name of the value to retrieve.
 * @return String value.
 */
public static String[] registryGetStringArray(HKEY root, String key, String value) {
    HKEYByReference phkKey = new HKEYByReference();
    int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ | WinNT.KEY_WOW64_32KEY, phkKey);
    if (rc != W32Errors.ERROR_SUCCESS) {
        throw new Win32Exception(rc);
    }
    try {
        IntByReference lpcbData = new IntByReference();
        IntByReference lpType = new IntByReference();
        rc = Advapi32.INSTANCE.RegQueryValueEx(
                phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
        if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
            throw new Win32Exception(rc);
        }
        if (lpType.getValue() != WinNT.REG_MULTI_SZ) {
            throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ");
        }
        Memory data = new Memory(lpcbData.getValue());
        rc = Advapi32.INSTANCE.RegQueryValueEx(
                phkKey.getValue(), value, 0, lpType, data, lpcbData);
        if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
            throw new Win32Exception(rc);
        }
        ArrayList<String> result = new ArrayList<>();
        int offset = 0;
        while (offset < data.size()) {
            String s = data.getString(offset, true);
            offset += s.length() * Native.WCHAR_SIZE;
            offset += Native.WCHAR_SIZE;
            result.add(s);
        }
        return result.toArray(new String[result.size()]);
    } finally {
        rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
        if (rc != W32Errors.ERROR_SUCCESS) {
            throw new Win32Exception(rc);
        }
    }
}
 
Example 11
Source File: Nc4DMRCompiler.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
int[] getVars(int gid) throws DapException {
  int ret, n;
  IntByReference ip = new IntByReference();
  errcheck(ret = nc4.nc_inq_nvars(gid, ip));
  n = ip.getValue();
  int[] ids = new int[n];
  if (n > 0)
    errcheck(ret = nc4.nc_inq_varids(gid, ip, ids));
  return ids;
}
 
Example 12
Source File: Advapi32Util.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get a registry DWORD value.
 *
 * @param root Root key.
 * @param key Registry key path.
 * @param value Name of the value to retrieve.
 * @return Integer value.
 */
public static int registryGetIntValue(HKEY root, String key, String value) {
    HKEYByReference phkKey = new HKEYByReference();
    int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ | WinNT.KEY_WOW64_32KEY, phkKey);
    if (rc != W32Errors.ERROR_SUCCESS) {
        throw new Win32Exception(rc);
    }
    try {
        IntByReference lpcbData = new IntByReference();
        IntByReference lpType = new IntByReference();
        rc = Advapi32.INSTANCE.RegQueryValueEx(
                phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
        if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
            throw new Win32Exception(rc);
        }
        if (lpType.getValue() != WinNT.REG_DWORD) {
            throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ");
        }
        IntByReference data = new IntByReference();
        rc = Advapi32.INSTANCE.RegQueryValueEx(
                phkKey.getValue(), value, 0, lpType, data, lpcbData);
        if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
            throw new Win32Exception(rc);
        }
        return data.getValue();
    } finally {
        rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
        if (rc != W32Errors.ERROR_SUCCESS) {
            throw new Win32Exception(rc);
        }
    }
}
 
Example 13
Source File: NotesIDTable.java    From domino-jna with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a single note id to the table
 * 
 * @param noteId note id
 * @return true if added
 */
public boolean addNote(int noteId) {
	checkHandle();
	IntByReference retInserted = new IntByReference();
	short result;
	if (PlatformUtils.is64Bit()) {
		result = NotesNativeAPI64.get().IDInsert(m_idTableHandle64, noteId, retInserted);
	}
	else {
		result = NotesNativeAPI32.get().IDInsert(m_idTableHandle32, noteId, retInserted);
	}
	NotesErrorUtils.checkResult(result);
	int retInsertedAsInt = retInserted.getValue();
	return retInsertedAsInt != 0;
}
 
Example 14
Source File: Advapi32Util.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Get a registry REG_EXPAND_SZ value.
 *
 * @param root Root key.
 * @param key Registry path.
 * @param value Name of the value to retrieve.
 * @return String value.
 */
public static String registryGetExpandableStringValue(HKEY root, String key, String value) {
    HKEYByReference phkKey = new HKEYByReference();
    int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ | WinNT.KEY_WOW64_32KEY, phkKey);
    if (rc != W32Errors.ERROR_SUCCESS) {
        throw new Win32Exception(rc);
    }
    try {
        IntByReference lpcbData = new IntByReference();
        IntByReference lpType = new IntByReference();
        rc = Advapi32.INSTANCE.RegQueryValueEx(
                phkKey.getValue(), value, 0, lpType, (char[]) null, lpcbData);
        if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
            throw new Win32Exception(rc);
        }
        if (lpType.getValue() != WinNT.REG_EXPAND_SZ) {
            throw new RuntimeException("Unexpected registry type " + lpType.getValue() + ", expected REG_SZ");
        }
        char[] data = new char[lpcbData.getValue()];
        rc = Advapi32.INSTANCE.RegQueryValueEx(
                phkKey.getValue(), value, 0, lpType, data, lpcbData);
        if (rc != W32Errors.ERROR_SUCCESS && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
            throw new Win32Exception(rc);
        }
        return Native.toString(data);
    } finally {
        rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue());
        if (rc != W32Errors.ERROR_SUCCESS) {
            throw new Win32Exception(rc);
        }
    }
}
 
Example 15
Source File: NotesOOOUtils.java    From domino-jna with Apache License 2.0 5 votes vote down vote up
/**
 * This function returns a flag which defines how to treat internet emails.<br>
 * This functional call is optional.<br>
 * If this flag is set to TRUE OOO notifications will not be generated for<br>
 * email originating from the internet.  The default for this flag is TRUE.
 * 
 * @return true if excluded
 */
public boolean isExcludeInternet() {
	checkHandle();
	
	IntByReference bExcludeInternet = new IntByReference();
	short result = NotesNativeAPI.get().OOOGetExcludeInternet(m_pOOOContext, bExcludeInternet);
	NotesErrorUtils.checkResult(result);
	return bExcludeInternet.getValue()==1;
}
 
Example 16
Source File: DXLExporter.java    From domino-jna with Apache License 2.0 5 votes vote down vote up
public DXLExporter() {
	IntByReference rethDXLExport = new IntByReference();
	short result = NotesNativeAPI.get().DXLCreateExporter(rethDXLExport);
	NotesErrorUtils.checkResult(result);
	m_hExporter = rethDXLExport.getValue();
	if (m_hExporter==0) {
		throw new NotesError(0, "Failed to allocate DXL exporter");
	}
	NotesGC.__memoryAllocated(this);
}
 
Example 17
Source File: WindowsTerminal.java    From lanterna with GNU Lesser General Public License v3.0 4 votes vote down vote up
private int getConsoleOutputMode() {
    IntByReference lpMode = new IntByReference();
    WINDOWS_CONSOLE.GetConsoleMode(CONSOLE_OUTPUT_HANDLE, lpMode);
    return lpMode.getValue();
}
 
Example 18
Source File: WindowsTerminal.java    From lanterna with GNU Lesser General Public License v3.0 4 votes vote down vote up
private int getConsoleOutputMode() {
	IntByReference lpMode = new IntByReference();
	Wincon.INSTANCE.GetConsoleMode(CONSOLE_OUTPUT.getHandle(), lpMode);
	return lpMode.getValue();
}
 
Example 19
Source File: CFNumber.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public int getInt() {
  IntByReference ibr = new IntByReference();
  if (CFLibrary.INSTANCE.CFNumberGetValue(this, CFLibrary.CFNumberType.kCFNumberSInt64Type, ibr))
    return ibr.getValue();
  return -1;
}
 
Example 20
Source File: WdmDll.java    From OpenDA with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Returns the number of timeSteps between the given dates.
 *
 * @param startDate
 * @param endDate
 * @param timeUnit
 * @param timeStep
 * @return numberOfTimeSteps.
 */
public int getNumberOfTimeSteps(int[] startDate, int[] endDate, int timeUnit, int timeStep) {
    IntByReference numberOftimeSteps = new IntByReference(-1);
    nativeDLL.timdif_(startDate, endDate, new IntByReference(timeUnit), new IntByReference(timeStep), numberOftimeSteps);
    return numberOftimeSteps.getValue();
}