开发者

Using HIDController on Delphi 2010

开发者 https://www.devze.com 2023-03-10 22:10 出处:网络
I have an application that uses HID Controller on delphi 7 but now I need to use it on Delphi 2010(license problems) but I\'ve found some compatibility problems of this HIDController in this 开发者_开

I have an application that uses HID Controller on delphi 7 but now I need to use it on Delphi 2010(license problems) but I've found some compatibility problems of 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 who faced the same problem could help me. I now its possible I just can't figure how.


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

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

Major trouble is in string and AnsiString declaration, so this file resolve this incompatibility.

P.S. Use zipped version of file from the post.


Apparently the "device can not be opened" problem (Natalia) has also to do with unicode characters. The new version of HIDController pointed to in answer 1 does not solve this problem.

Solution: Change the type of the last parameter of TJvHIDPnPInfo.Create (unit JvHIDController.pas) in "PAnsiChar" in stead of "PChar". Do not forget to change also the typecast where the routine is "called".

p.s. the links to "Modified source file" and "zipped version" in answer 1 are dead.


In Delphi 2010 all vars declared as string are unicode type (wide string). When porting components from earlier versions (Delphi 7) to newer version always check all vars declared as string and pchar. In newer version this vars needs to be declared as AnsiString and PAnsyChar which will most likely solve your problems. Of course you have to make sure if you call any dll functions to call proper one _W (when calling function with wide string params) or _A when using AnsiString. However another thing to mention is to check documentation for HID to see what type of params are accepted and use them properly within newer delphi version. I wrote my hid controller (similar) from scratch while there was no existing one by that time and of course when I ported it to Delphi2010 different string types was my main issue. It was similar when I wrote WinUsbController to use WinUSB driver. It's mandatory to read manuals (MSDN), check in headers (.h) and read delphi help (for string) to match proper data types.

0

精彩评论

暂无评论...
验证码 换一张
取 消