protected Win32Exception(int code, HRESULT hr) { this(code, hr, Kernel32Util.formatMessage(hr)); }
private static IOException toException(int error) { return new IOException(Kernel32Util.formatMessage(error)); }
private static IOException toException(int error) { return new IOException(Kernel32Util.formatMessage(error)); }
private static IOException toException(int error) { return new IOException(Kernel32Util.formatMessage(error)); }
/** * Format a system message from an error code. * * @param code * Error code, typically a result of GetLastError. * @return Formatted message. */ public static String formatMessageFromLastErrorCode(int code) { return formatMessage(W32Errors.HRESULT_FROM_WIN32(code)); }
/** * Format a message from an HRESULT. * * @param code * HRESULT * @return Formatted message. */ public static String formatMessage(HRESULT code) { return formatMessage(code.intValue()); }
public void suspend() throws SystemException { final boolean success = kernel32.SetSystemPowerState( true, false ); if (!success) { throw new SystemException(Kernel32Util.formatMessage(kernel32.GetLastError())); } }
public void hibernate() throws SystemException { final boolean success = kernel32.SetSystemPowerState( false, false ); if (!success) { throw new SystemException(Kernel32Util.formatMessage(kernel32.GetLastError())); } }
/** * Throw new exception. * * @param hr * the hr */ public static void checkRC(HRESULT hr) { if (FAILED(hr)) { String formatMessage; try { formatMessage = Kernel32Util.formatMessage(hr) + "(HRESULT: " + Integer.toHexString(hr.intValue()) + ")"; } catch (LastErrorException ex) { // throws if HRESULT can't be resolved formatMessage = "(HRESULT: " + Integer.toHexString(hr.intValue()) + ")"; } throw new COMException(formatMessage, hr); } }
void doClose(long mappingPtr) throws IOException { if (mFileHandle == null) { if (!cKernel.VirtualFree(mappingPtr, 0, 0x8000)) { // MEM_RELEASE int error = cKernel.GetLastError(); throw new IOException(Kernel32Util.formatMessage(error)); } } else { cKernel.UnmapViewOfFile(new Pointer(mappingPtr)); closeHandle(mMappingHandle); closeHandle(mFileHandle); } }
public void reboot() throws SystemException { final boolean success = advapi32.InitiateSystemShutdown( null, null, new WinDef.DWORD(0), true, true ); if (!success) { throw new SystemException(Kernel32Util.formatMessage(kernel32.GetLastError())); } }
public void shutdown() throws SystemException { final boolean success = advapi32.InitiateSystemShutdown( null, null, new WinDef.DWORD(0), true, false ); if (!success) { throw new SystemException(Kernel32Util.formatMessage(kernel32.GetLastError())); } }
void doClose(long mappingPtr) throws IOException { if (mFileHandle == null) { if (!cKernel.VirtualFree(mappingPtr, 0, 0x8000)) { // MEM_RELEASE int error = cKernel.GetLastError(); throw new IOException(Kernel32Util.formatMessage(error)); } } else { cKernel.UnmapViewOfFile(new Pointer(mappingPtr)); closeHandle(mMappingHandle); closeHandle(mFileHandle); } }
void doClose(long mappingPtr) throws IOException { if (mFileHandle == null) { if (!cKernel.VirtualFree(mappingPtr, 0, 0x8000)) { // MEM_RELEASE int error = cKernel.GetLastError(); throw new IOException(Kernel32Util.formatMessage(error)); } } else { cKernel.UnmapViewOfFile(new Pointer(mappingPtr)); closeHandle(mMappingHandle); closeHandle(mFileHandle); } }
formatMessage.append(Kernel32Util.formatMessage(hr)); } catch (LastErrorException ex) {
throw new IOException(Kernel32Util.formatMessage(error)); throw new FileNotFoundException(Kernel32Util.formatMessage(error));
throw new IOException(Kernel32Util.formatMessage(error)); throw new FileNotFoundException(Kernel32Util.formatMessage(error));
String formatMessageFromHR = Kernel32Util.formatMessage(hr); throw new COMException("getUnknownId: " + formatMessageFromHR, hr);
return t; } else { String formatMessageFromHR = Kernel32Util.formatMessage(hr); throw new COMException("queryInterface: " + formatMessageFromHR, hr);
throw new SystemException( "Cannot obtain required privileges: " + Kernel32Util.formatMessage(kernel32.GetLastError()) );