Desktop Functions: Smart Device Functions:
|
HidD_GetSerialNumberString (hid)
Retrieves the serial number string from a connected device. C# Signature:
[DllImport("hid.dll", SetLastError=true)] VB Signature:
Declare Function HidD_GetSerialNumberString Lib "hid.dll" (TODO) As TODO User-Defined Types:None. Alternative Managed API:Do you know one? Please contribute it! Notes:None. Tips & Tricks:The string that is returned is unicode and therefore needs to be converted for most use cases. Sample Code:string devicePath = "<your device path>"; // Open the device deviceHandle = CreateFile(devicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero); string sn = ""; byte[] buffer = new byte[128]; // attempt to read the serial number string if (HidD_GetSerialNumberString(HIDDeviceHandle, buffer, buffer.Length)) {
// convert from unicode to the default encoding } // Clear out the '\0' characters sn = sn.Remove(sn.IndexOf('\0')); Please edit this page!Do you have...
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more). |
|