4 messages in net.java.dev.jna.usersRe: [jna-users] Pointer to a caller-a...
FromSent OnAttachments
Dave KennedyNov 7, 2008 12:48 pm.java
Timothy WallNov 7, 2008 1:08 pm 
Dave KennedyNov 7, 2008 1:31 pm.java, .java, .java
Timothy WallNov 7, 2008 1:45 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Pointer to a caller-allocated GUID bufferActions...
From:Timothy Wall (twal@dev.java.net)
Date:Nov 7, 2008 1:08:07 pm
List:net.java.dev.jna.users

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.