Using HIDController at Delphi 2010

I have an application that uses the HID Controller on delphi 7, but now I need to use it on Delphi 2010 (licensing issues) ve found some compatibility problems for this HIDController in this delphi 2010. This library is part of Project JEDI.

I notice some questions from people using this library (JvHidDeviceController component) with Delphi 2010 and Win7. Maybe someone faced with the same problem can help me. I am now possible, I just can’t understand how.

+1
source share
3 answers

This is the working code for D2010: Use the package from this site: HIDController DPK

And replace JvHidControllerClass.pas with the version from this site: Changed source file

The main problem is declaring the string and AnsiString, so this file resolves this incompatibility.

PS Use the zipped version of the file from the message.

+3
source

Apparently, the “device cannot be opened” problem (Natalia) also relates to Unicode characters. The new version of HIDController, indicated in answer 1, does not solve this problem.

Solution: Change the type of the last parameter TJvHIDPnPInfo.Create (unit JvHIDController.pas) to " PAnsiChar " instead of "PChar". Remember to also change the type when the procedure is called "called".

ps links to "Modified source file" and "zipped version" in answer 1 are dead.

+1
source

In Delphi 2010, all vars declared as strings are unicode types (wide strings). When porting components from earlier versions (Delphi 7) to a newer version, always check all vars declared as a string and pchar. In a newer version, these vars should be declared as AnsiString and PAnsyChar, which are likely to solve your problems. Of course, you must make sure that you call any dll functions to call the correct _W (when calling the function with wide string parameters) or _A when using AnsiString. However, one more thing to mention is to check the documentation for the HID to see what types of parameters are accepted and to use them correctly in the new version of delphi. I wrote my hidden controller (similar) from scratch, while there weren’t any existing ones by that time, and, of course, when I ported it to Delphi2010, different types of lines were my main problem. It was like when I wrote WinUsbController to use the WinUSB driver. Be sure to read the manuals (MSDN), check the headers (.h), and read the delphi help (for the string) to match the corresponding data types.

0
source

Source: https://habr.com/ru/post/908886/


All Articles