I think your Java struct definition is incorrect:
// C code
typedef struct _GUID {
ULONG Data1;
USHORT Data2;
USHORT Data3;
UCHAR Data4[8];
} GUID
typedef GUID *LPGUID;
ULONG = Java integer
USHORT = Java short
UCHAR = Java byte
You can inline-initialize the byte[] field to avoid needing an
explicit ctor (your ctor was allocating memory incorrectly anyway).
Note that the resulting size is supposed to be 16 bytes.
// Correct Java code
public static class GUID extends Structure {
public int data1;
public short data2;
public short data3;
public byte[] data4 = new byte[8];
}
On Nov 7, 2008, at 3:48 PM, Dave Kennedy wrote:
Hi,
I need to call HidD_GetHidGuid as defined below.
How is LPGUID HidGuid defined in JNA?
Is the code in the attached file correct?
Thanks,
Dave
The HidD_GetHidGuid routine returns the device interface GUID for
HIDClass devices.
http://msdn.microsoft.com/en-us/library/ms790927.aspx
VOID
HidD_GetHidGuid(
OUT LPGUID HidGuid
);
Parameters
HidGuid
Pointer to a caller-allocated GUID buffer that the routine uses
to return the device interface GUID for HIDClass devices.
GUID
Globally unique identifier. A 16-byte quantity that is unique,
having been generated from the unique identifier on a network card,
the current date and time, and a sequence number. This combination
of variables is used to allow any party to create identifiers that
will be guaranteed not to match another GUID. For more information
see the topic, Using GUIDs in Drivers.