Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 625409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:18:22+00:00 2026-05-13T19:18:22+00:00

I am writing a .NET application that can communicate with HID devices. I want

  • 0

I am writing a .NET application that can communicate with HID devices. I want to be able to retrieve and parse the Manufactures String from the device firmware. I know that in the hid.dll there is a method called HidD_GetManufacturerString. MSDN describes this method as follows:

 BOOLEAN   HidD_GetManufacturerString(
     IN HANDLE  HidDeviceObject,
     OUT PVOID  Buffer,
     IN ULONG  BufferLength
     );

The wrapper i am using for this method looks like this…

[DllImport("hid.dll", SetLastError = true)]
        internal static extern Boolean HidD_GetManufacturerString(
            SafeFileHandle hFile,
            Byte[] SerialNumber,
            Int32 SerianNumberLength);

I need to know two things. First, how do I know what size to initialize the SerialNumber buffer to? When I do operations like GetFeatureReport I know what size to make the buffer because I can retrieve the max Feature Report Length from the device Attributes using HidD_GetAttributes(); Unfortunatly, this method doesn’t give me any info of the length of the Manufacturer string, serial number string, product name string, etc.

My second question is, what is the correct way to parse the byte array that is returned into a string? I tried using

System.Text.Encoding.ASCII.GetString(MfrBuffer)

but I get a strange result. For a product manufacturered by Dell my string looks like this “D\0e\0l\0l\0\0\0\0\0…” the “\0” continue on to the end of the buffer that I passed. How do I parse this to “Dell”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:18:23+00:00Added an answer on May 13, 2026 at 7:18 pm

    It looks like “Dell” is coming back as a unicode string, (you can tell by the \0 between each character). so you would use.

    System.Text.Encoding.Unicode.GetString(MfrBuffer)
    

    As for the buffer length, the documentation for this function 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).

    So the buffer needs to be (126+1) * 2 bytes in size.

    Then you can use TrimEnd("\0".ToCharArray()) to remove the extra trailing \0s

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a small .NET application that can produce SWF files, and I need
I'm writing a .NET command-line application that will migrate users from an existing database
I'm writing an ASP.Net Web Application that can be deployed to Web Farms. I've
I am writing a quick-and-dirty in-house ASP.NET application that needs to be able to
In web application [asp.net] shall we write code that can retrive data from datbase
I am writing a .NET WinForms application that needs to display a list of
I'm writing an ASP.net application that uses Windows Identity Foundation. My ASP.net application uses
I currently have an application I'm writing in c# (using .NET) that requires me
I am writing a web application on Asp.Net MVC 3. Assume that we have
I am writing .NET 4 application, witch synchronize data. I want to use Firebird

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.