Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
C++DelphiTech Partner

Human Interface Devices Communicator For Delphi/C++ Builder On Windows

Communicating with Human Interface Devices such as Alphanumeric display, Bar Code Reader, Sensors, Volume control on Speakers/Headsets becomes a primary use case for real-world applications. Do you spend more time in building libraries to communicate with HID for your Delphi/C++ and Lazarus Applications? WINSOFT Provides a powerful library to get the job done. It uses the standard Windows HID API.


  • Able to notify on HID Device arrival and removal.
  • Can retrieve all the HID devices information available in the System.
  • Flexible to getting/set Feature Report for the HID devices.
  • Works with Windows 32/64-bit applications.

Versions Supported: Delphi/C++ Builder 5 – Delphi 10.4 and Lazarus 2.0.8.

Platforms: Windows;  

Steps to Download and use the Native HID Library:

  1. Download Native HID and Unzip the file.
  2. Navigate to the Library folder for different Versions. e.g) Delphi10.4.
  3. Read the Readme.txt file to know about features and copyright information.
  4. Create a Windows VCL Application and use Hid.pas in the uses section.
  5. Include the Library folder into Project->Options->Delphi Compiler->Search Path.
  6. Compile and check for using the library.

NativeHID Download and Use demo:

Key HID concepts:
Report -Reports are the actual data that is exchanged between a device and a software client.

  •  Input Report – Data sent from the HID device to the application, typically when the state of a control changes.
  • Output Report – Data sent from the application to the HID device, for example to the LEDs on a keyboard.
  • Feature Report -Data that can be manually read and/or written, and are typically related to configuration information.

Report Descriptor – The Report Descriptor describes the format and meaning of the data that the device supports.
UsageTables – Contain a list with descriptions of Usages, which describe the intended meaning and use of a particular item described in the Report Descriptor. For example, a Usage is defined for the left button of a mouse.  USB-IF WorkGroup Publishes the Usage Tables. See USB-IF HID Specifications.

How to build applications using Native HID library:

1. Open Rad Studio 10.4 and Create a Windows VCL Application, use Hid.pas in the uses section.
2. Include the Library folder into Project->Options->Delphi Compiler->Search Path.
3. Device := THidDevice.Create; // Creates an Instance of THidDevice

  • OnDeviceArrival– Provide the DeviceName which arrives at the system. Using DeviceName you can open the device, show the device properties.
  • OnDeviceRemoved – Provide the DeviceName which removed from the system.
  • Get/SetFeatureReport – Use this to manually Read/Write Related to configuration information.
  • GetInputReport – Get the data sent by HID Device for the Report ID.
  • SetOutputReport – Set the data to HID Device for the Report ID.

4. Device.Open // Open the HID Device.

5. ShowDeviceProperties. with Device do       try         AddLine('Vendor ID: ' + IntToHex(VendorID,4));    AddLine('Product ID: ' + IntToHex(ProductID,4));    AddLine('Version Number: ' + IntToHex(VersionNumber,4));    AddLine('Serial Number: ' + SerialNumber);    AddLine('Manufacturer: ' + Manufacturer );    AddLine('Product: ' + Product);    AddLine('Usage Page: ' + IntToStr(UsagePage));         AddLine('Usage: ' + IntToStr(Usage));         AddLine('Input Report length: ' + IntToStr(InputReportLength));    AddLine('Output Report Length: ' + IntToStr(OutputReportLength));    AddLine('Feature Report Length :  ' + IntToStr(FeatureReportLength));    AddLine('Input Buffer Count :  ' + IntToStr(InputBufferCount));    for I := 1 to 255 do      if HasString[I] then        AddLine('String ' + IntToStr(I) + ':' + Strings[I])      else                Break;       except on E: Exception do             AddLine('Exception: ' + E.Message);       end;

6. Get Device Names, var   DeviceNames : TWStringDynArray; begin   With Device do     DeviceNames := Enumerate; end;

7.For each DeviceNames GetFeatureReport With Device do if FeatureReportSupported then    for J := 0 to 9 do      try        AddLine('Feature report' + IntToStr(J) + ':' +  ByteArrayToString(GetFeatureReport(J)));      except On E: Exception do        AddLine('Feature Report' + IntToStr(J) + 'Exception : ' + E.Message);      end;

8. For each DeviceNames GetInputReport : if InputReportSupported then    for J := 0 to 9 do      try        AddLine('Input report' + IntToStr(J) + ':' +  ByteArrayToString(GetInputReport(J)));      except On E: Exception do        AddLine('Input Report' + IntToStr(J) + 'Exception : ' + E.Message);      end;

9. For each DeviceNames Read by reopening the Device in Read only: With Device do   if ReadSupported then  begin   if active then     Close;                     Open(DeviceNames[I],True,False);  for J := 0 to 9 do       try         AddLine('Read' + ByteArrayToString(Read(300)));       except On E: Exception do         AddLine('Read exception' + E.Message);       end;  end;

10. Device.close; // close the HID Device.

Native HID Library Code demo :

Conclusion:  It’s quite easy to interact with HID in your applications. WINSOFT saved our time in nailing the Windows HID API and helped us to build quickly using the NativeHID Library.  

Head over and check out the full WINSOFT Native HID Library for Access in Delphi and C++Builder.

Like what you see? You can get the Native HID Library and over 100 other fantastic WinSoft components with our Enterprise Component Pack. For a limited time, when you purchase RAD Studio Enterprise or Architect Edition at special Upgrade Pricing, you will also get this package of third-party software worth over $13,000, including the full WinSoft Component Library, at NO EXTRA COST! Step up to RAD Studio 10.4.1 today!

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.