/** * Closes the handle in the reference * * @param ref The handle reference - ignored if {@code null} * @see #closeHandle(WinNT.HANDLE) */ public static void closeHandleRef(HANDLEByReference ref) { closeHandle((ref == null) ? null : ref.getValue()); }
/** * Invokes {@link #closeHandle(WinNT.HANDLE)} on each handle. If an exception * is thrown for a specific handle, then it is accumulated until all * handles have been closed. If more than one exception occurs, then it * is added as a suppressed exception to the first one. Once closed all * handles, the accumulated exception (if any) is thrown * * @param handles The handles to be closed * @see Throwable#getSuppressed() */ public static void closeHandles(HANDLE... handles) { Win32Exception err = null; for (HANDLE h : handles) { try { closeHandle(h); } catch(Win32Exception e) { if (err == null) { err = e; } else { err.addSuppressedReflected(e); } } } if (err != null) { throw err; } }
} finally { try { closeHandle(hFile); } catch(Win32Exception e) { if (err == null) {
} finally { try { closeHandle(snapshot); } catch(Win32Exception e) { if (we == null) {
if (!WinBase.INVALID_HANDLE_VALUE.equals(hToken)) { try { Kernel32Util.closeHandle(hToken); } catch(Win32Exception e) { if (err == null) {