3

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.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
Nathalia
  • 41
  • 1
  • 3
  • Do you have use the same version for Delphi 2010 as you have used for 7? They are probably not compatible. – Toon Krijthe Jun 07 '11 at 21:37
  • 1
    What are "some compatibility problems"? We can't see your screen from here, and you've asked nothing that can be answered here. You mention "the same problem", but since you don't say what the problem is no one can say whether they've faced the same one or not. You need to provide a lot more information before anyone can possibly help you. – Ken White Jun 07 '11 at 22:11
  • I just use the unit 'JvHidControllerClass' which works in Delphi 7 and 2010..XE too. It's in the HidController.dpk package which I compile and install into a new IDE. The readme with it shows "1.0.34 introduces several Windows version dependent methods." so this should give you the version. – Brian Frost Jun 08 '11 at 11:02
  • Brian, i'm using the same version as you. I can intall the component on Delhpi 2010 but when i try to compile the project using "JvHidDeviceController" it gives the error: "device cannot be opened". Shearching the web i found some people talking about Delphi 2010 incompatibility. Now i don't know what the real problem is... – Nathalia Jun 09 '11 at 17:40
  • @Nathalia: I'm on sticky ground then, I'm simply using it to get at a temperature probe which is known to be an HID device. Have you tried the sample code that ships with the JvHid stuff? I'm sure that it should be easy to test open the mouse or something. Check also that you can see the 'inserted' and 'removed' events with a breakpoint. This may point you to a problem with how you are handling events. – Brian Frost Jun 11 '11 at 18:07
  • @Brian Frost, I tried the samples but it gives me the same error i mentioned. I used the breakpoint as you said but the only thing i could notice is that the HidFileHandle is an INVALID_HANDLE_VALUE. I dont think the problems is my device 'cause i can use it without problems with another library. I suppose there's some code that is not reconized by delphi 2010 on the library code but i could'nt find something yet. Before using it on your app have you changed something there? I'll keep trying to find something usefull! thank you :) – Nathalia Jun 14 '11 at 18:07
  • Tracking the error i found something. When filling the device list, jvHidControllerClass ignores all of my plugged devices because it considers they are "unreadable". This happens because the handle returned by CreateFile function is invalid. – Nathalia Jun 14 '11 at 19:32
  • As my devices are not unreadable(or shouldn't be) and work fine, i don't now what's the problem! – Nathalia Jun 14 '11 at 19:35

3 Answers3

3

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.

LU RD
  • 34,438
  • 5
  • 88
  • 296
nepe
  • 31
  • 2
2

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.

Dany
  • 21
  • 1
0

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.

Nix
  • 581
  • 5
  • 20