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 667273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:54:36+00:00 2026-05-13T23:54:36+00:00

In Win32_DiskDrive. There’s a Capabilities Property which has a type of System.UInt16[]. Am trying

  • 0

In Win32_DiskDrive. There’s a Capabilities Property which has a type of System.UInt16[].

Am trying to get the values by using GetProperty and convert it to string. But it keeps throwing an error (I don’t want to trap it) on Capabilities property.

The error was: InvalidCastException

Message: Object must implement IConvertible.

  • 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-13T23:54:37+00:00Added an answer on May 13, 2026 at 11:54 pm

    There’s the WMI Code Creator tool from Microsoft that can generate C#, Visual Basic .NET and VBScript code for you to run any WMI query and enumerate the results. It’s also very useful for exploring WMI namespaces and classes, so it’s a must-have when dealing with WMI.

    Now back to the question. From the System.UInt16[] syntax I assume that you’re using C#. Here’s sample C# code (generated by WMI Code Creator, with a few minor changes) that demonstrates how you can access individual elements of the Capabilities array:

    ManagementObjectSearcher searcher = 
        new ManagementObjectSearcher("root\\CIMV2", 
        "SELECT * FROM Win32_DiskDrive"); 
    
    foreach (ManagementObject queryObj in searcher.Get())
    {
        if(queryObj["Capabilities"] == null)
            Console.WriteLine("Capabilities: {0}", queryObj["Capabilities"]);
        else
        {
            UInt16[] arrCapabilities = (UInt16[])(queryObj["Capabilities"]);
            foreach (UInt16 arrValue in arrCapabilities)
            {
                Console.WriteLine("Capabilities: {0}", arrValue);
            }
        }
        Console.WriteLine();
    }
    

    To convert a UInt16 value to a string, you can use the ToString method, for example:

    foreach (UInt16 arrValue in arrCapabilities)
    {
        Console.WriteLine(arrValue.ToString());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have using System.Management; However, I keep getting this error: The type or namespace
Background I've been using Win32_DiskDrive to find flash memory (usb pens, SD cards, etc.),
In Win32 there's a lot of places where flags values are specified with DWORD
I'm trying to get info about installed software on local computers (one is Windows
Does anybody know what is the Signature property of the Win32_DiskDrive WMI class? Is
Win32 has the winmm library, which allows joystick events to be captured in the
A Win32 API was invoked in my DLL, which will be loaded by SYSTEM
I am trying to get the physical device size of a connected USB flash
In Win32, is there any way to get a unique cpu cycle count or
I'm trying to get the HDD Serial Number trough WMI but I'm not sure

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.