简体   繁体   English

在 Delphi 2010 上使用 HIDController

[英]Using HIDController on Delphi 2010

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 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.我注意到人们在 Delphi 2010 和 Win7 中使用这个库(JvHidDeviceController 组件)的一些问题。 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这是 D2010 的工作代码:使用来自此站点的 package: HIDController DPK

And replace JvHidControllerClass.pas with version from this site: Modified source file并将 JvHidControllerClass.pas 替换为来自此站点的版本:修改后的源文件

Major trouble is in string and AnsiString declaration, so this file resolve this incompatibility.主要问题在于字符串和 AnsiString 声明,所以这个文件解决了这个不兼容问题。

PS Use zipped version of file from the post. PS 使用帖子中文件的压缩版本

Apparently the "device can not be opened" problem (Natalia) has also to do with unicode characters.显然“设备无法打开”问题(Natalia)也与 unicode 字符有关。 The new version of HIDController pointed to in answer 1 does not solve this problem.答案 1 中指向的新版本 HIDController 并没有解决这个问题。

Solution: Change the type of the last parameter of TJvHIDPnPInfo.Create (unit JvHIDController.pas) in " PAnsiChar " in stead of "PChar".解决方法:将“ PAnsiChar ”中的TJvHIDPnPInfo.Create (单位JvHIDController.pas)的最后一个参数的类型改为“PChar”。 Do not forget to change also the typecast where the routine is "called".不要忘记更改“调用”例程的类型转换。

ps the links to "Modified source file" and "zipped version" in answer 1 are dead. ps答案1中“修改后的源文件”和“压缩版本”的链接已失效。

In Delphi 2010 all vars declared as string are unicode type (wide string).在 Delphi 2010 中,所有声明为字符串的变量都是 unicode 类型(宽字符串)。 When porting components from earlier versions (Delphi 7) to newer version always check all vars declared as string and pchar.将组件从早期版本(Delphi 7)移植到较新版本时,始终检查所有声明为字符串和 pchar 的变量。 In newer version this vars needs to be declared as AnsiString and PAnsyChar which will most likely solve your problems.在较新的版本中,需要将此变量声明为 AnsiString 和 PAnsyChar,这很可能会解决您的问题。 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.当然,您必须确保是否调用任何 dll 函数来调用正确的 _W(使用宽字符串参数调用 function 时)或使用 AnsiString 时的 _A。 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.但是要提到的另一件事是检查 HID 的文档以查看接受哪些类型的参数并在较新的 delphi 版本中正确使用它们。 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.我从头开始编写了我的隐藏 controller (类似),而当时还没有现有的,当然,当我将它移植到 Delphi2010 时,不同的字符串类型是我的主要问题。 It was similar when I wrote WinUsbController to use WinUSB driver.当我编写 WinUsbController 以使用 WinUSB 驱动程序时,情况类似。 It's mandatory to read manuals (MSDN), check in headers (.h) and read delphi help (for string) to match proper data types.必须阅读手册 (MSDN)、签入标题 (.h) 并阅读 delphi 帮助(用于字符串)以匹配正确的数据类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM