HidD_GetProductString 得不到>126bytes(53 wild character)

auto_dut   2009-6-21 11:07 楼主
一个关于win API     HidD_GetProductString 得不到>126bytes(53 wild character) string的问题:

各位usb大牛们  帮帮忙啦
=================

Hello everyone!

I have a problem when I use HidD_GetIProductString API to
get my HID UPS's ProductString.
It always return FALSE.
My Procuct String is about 132 bytes. It is a unicode string.

And in MSDN - HidD_GetProductString help content ,
it says:
The maximum possible number of characters in an embedded string is device specific. For USB devices, the maximum string length is 126 wide characters (not including the terminating NULL character).

My question is how to get a 132 bytes product string in my
winXP application? use another API function or...?
My customer didn't want to short the Produt String.

And I note that , when I connect the HID UPS to windows OS,
in the OS's Control panel/Power Option/Power Meter/Detail Info/battery status page, there's no battery name. and the
product string cann't be shown, it will only show "Prod" .

Does anyone know how to resolve it?
THANKS !

HidD_GetIndexedString refer to:
http://msdn.microsoft.com/en-us/library/ms790921.aspx

HidD_GetProductString refer to:
http://msdn.microsoft.com/en-us/library/ms790920.aspx



========================


My string is 132 bytes (66 characters) .
And I use CATC USB Chief to catch the bus data.
after usb device plug into winXP,
there are 3 Get_Desc(produt string).
No.1 Get_Desc wLength is 255, and get whole of string 132 bytes.
No.2 Get_Desc is same as No.1
No.3 Get_Desc wLength is 102 and only get 102 bytes.
and enumeration seems OK.

But in my MFC Application software
HidD_GetProductString still cann't return right value.
When GetLastError(), I got error code = 1784 (Error_Invalid_User_Buffer).
I don't know why?


===========================


Yes, it maybe a Windows API issue.

It's about the HidD_GetProductString().
When I change my usb device's ProductString to less than 126 bytes(63 wild character), the API function can get string well.
And the function will fail once I add the string to more than 126 bytes.

My usb device is a UPS which have a USB port.
It is a HID Power Device.
And I also find that winXP PowerMeter will also fail to
recognize the ups battery's long product string.
But the winXP device manager can recognize the string.

If you have a usb device under develop, you can try it.

回复评论

暂无评论,赶紧抢沙发吧
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复