Java Code Examples for com.sun.jna.platform.win32.WinBase#INVALID_HANDLE_VALUE
The following examples show how to use
com.sun.jna.platform.win32.WinBase#INVALID_HANDLE_VALUE .
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: JKernel32.java From Flashtool with GNU General Public License v3.0 | 5 votes |
public static boolean openDevice() throws IOException { /* Kernel32RW.GENERIC_READ | Kernel32RW.GENERIC_WRITE not used in dwDesiredAccess field for system devices such a keyboard or mouse */ int shareMode = WinNT.FILE_SHARE_READ | WinNT.FILE_SHARE_WRITE; int Access = WinNT.GENERIC_WRITE | WinNT.GENERIC_READ; HandleToDevice = Kernel32.INSTANCE.CreateFile( Devices.getConnectedDeviceWin32().getDevPath(), Access, shareMode, null, WinNT.OPEN_EXISTING, 0,//WinNT.FILE_FLAG_OVERLAPPED, (WinNT.HANDLE)null); if (HandleToDevice == WinBase.INVALID_HANDLE_VALUE) throw new IOException(getLastError()); return true; }
Example 2
Source File: JKernel32.java From Flashtool with GNU General Public License v3.0 | 5 votes |
public static boolean openDeviceAsync() throws IOException { /* Kernel32RW.GENERIC_READ | Kernel32RW.GENERIC_WRITE not used in dwDesiredAccess field for system devices such a keyboard or mouse */ int shareMode = WinNT.FILE_SHARE_READ | WinNT.FILE_SHARE_WRITE; int Access = WinNT.GENERIC_WRITE | WinNT.GENERIC_READ; HandleToDevice = Kernel32.INSTANCE.CreateFile( Devices.getConnectedDeviceWin32().getDevPath(), Access, shareMode, null, WinNT.OPEN_EXISTING, WinNT.FILE_FLAG_OVERLAPPED, (WinNT.HANDLE)null); if (HandleToDevice == WinBase.INVALID_HANDLE_VALUE) throw new IOException(getLastError()); return true; }
Example 3
Source File: JKernel32.java From Flashtool with GNU General Public License v3.0 | 5 votes |
public static WinNT.HANDLE createEvent() throws IOException { WinNT.HANDLE hevent = kernel32.CreateEvent(null, false, false, null); int res = kernel32.GetLastError(); if (hevent == WinBase.INVALID_HANDLE_VALUE || res!=0) throw new IOException(JKernel32.getLastError()); return hevent; }
Example 4
Source File: JKernel32.java From Flashtool with GNU General Public License v3.0 | 5 votes |
public static boolean closeDevice() { boolean result = true; if (HandleToDevice != WinBase.INVALID_HANDLE_VALUE) { result = kernel32.CloseHandle(HandleToDevice); } HandleToDevice = WinBase.INVALID_HANDLE_VALUE; return result; }