[Disclaimer: I'm new to both JNA and Windows programming, and although
I've searched and read a lot, I still feel pretty clueless]
I'm using JNA to detect USB device addition/removal from a Java app.
I'm able to register for the specific device notifications I need and
I'm receiving the messages, processing them and forwarding them to the
app window just fine. My problem is that I'm struggling with getting
at the information from the notification message. The callback
function (http://msdn.microsoft.com/en-us/library/ms633573.aspx) looks
like this:
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_DEVICECHANGE
WPARAM wParam, // device-change event
LPARAM lParam // event-specific data
);
For the DBT_DEVICEARRIVAL event
(http://msdn.microsoft.com/en-us/library/aa363205(VS.85).aspx), the
lParam parameter above is:
"A pointer to a structure identifying the device inserted. The
structure consists of an event-independent header, followed by
event-dependent members that describe the device. To use this
structure, treat the structure as a DEV_BROADCAST_HDR structure, then
check its dbch_devicetype member to determine the device type."
DEV_BROADCAST_HDR
(http://msdn.microsoft.com/en-us/library/aa363246(VS.85).aspx) looks
like this:
typedef struct _DEV_BROADCAST_HDR {
DWORD dbch_size;
DWORD dbch_devicetype;
DWORD dbch_reserved;
} DEV_BROADCAST_HDR, *PDEV_BROADCAST_HDR;
How do I "treat the structure as a DEV_BROADCAST_HDR" using JNA? Any
guidance would be much appreciated.
Thanks,
Jim