4 messages in net.java.dev.jna.users[jna-users] Pointer to a caller-alloc...
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:[jna-users] Pointer to a caller-allocated GUID bufferActions...
From:Dave Kennedy (dave@gmail.com)
Date:Nov 7, 2008 12:48:00 pm
List:net.java.dev.jna.users
Attachments:

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.

/* * To change this template, choose Tools | Templates * and open the template in the editor. */

package win32;

import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Structure; import com.sun.jna.Platform; import com.sun.jna.ptr.PointerByReference;

public interface HIDLibrary extends W32API {

// GUID data type // Type GUID // Data1 As Long // Data2 As Integer // Data3 As Integer // Data4(7) As Byte // End Type public static class GUID extends Structure { public long data1; public int data2; public int data3; public byte[] date4; public GUID(int bufferSize) { date4 = new byte[bufferSize]; allocateMemory(bufferSize); } }

HIDLibrary INSTANCE = (HIDLibrary) Native.loadLibrary((Platform.isWindows() ? "hid" : "c"), HIDLibrary.class);

// Obtain the GUID for the HID class void HidD_GetHidGuid(GUID hidGuid); // Retrieves the HID's Vendor ID, Product ID, and Version Number. boolean HidD_GetAttributes(HANDLEByReference HidDeviceObject, PointerByReference Attributes); }