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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:12:08+00:00 2026-05-31T20:12:08+00:00

Just trying to pull off some SMART info from connected Hard Drives on any

  • 0

Just trying to pull off some SMART info from connected Hard Drives on any computer my application will run on.

I’m using WMI for a lot of other stuff in the program, and every question about SMART I’ve looked at makes reference to Win32_DiskDrive. However, the data in here is really quite minimal and probably not SMART – I’m searching for information such as ‘Spin Retry Count’. Any ideas?

  • 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-31T20:12:09+00:00Added an answer on May 31, 2026 at 8:12 pm

    You are using the wrong class (you want MSStorageDriver_ATAPISmartData).
    To change what attribute you want change byte SpinRetryCount = 0x0A; to whatever value you wish (e.g. 0x02 for throughput performance)

    [StructLayout(LayoutKind.Sequential)]
            public struct Attribute
            {
                public byte AttributeID;
                public ushort Flags;
                public byte Value;
                [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
                public byte[] VendorData;
            }
    
            static void getSMARTAttr()
            {
                try
                {
                    Attribute AtributeInfo;
                    ManagementScope Scope = new ManagementScope(String.Format("\\\\{0}\\root\\WMI", "localhost"), null);
                    Scope.Connect();
                    ObjectQuery Query = new ObjectQuery("SELECT VendorSpecific FROM MSStorageDriver_ATAPISmartData");
                    ManagementObjectSearcher Searcher = new ManagementObjectSearcher(Scope, Query);
                    byte SpinRetryCount = 0x0A;
                    int Delta = 12;
                    foreach (ManagementObject WmiObject in Searcher.Get())
                    {
                        byte[] VendorSpecific = (byte[])WmiObject["VendorSpecific"];
                        for (int offset = 2; offset < VendorSpecific.Length; )
                        {
                            if (VendorSpecific[offset] == SpinRetryCount)
                            {
    
                                IntPtr buffer = IntPtr.Zero;
                                try
                                {
                                    buffer = Marshal.AllocHGlobal(Delta);
                                    Marshal.Copy(VendorSpecific, offset, buffer, Delta);
                                    AtributeInfo = (Attribute)Marshal.PtrToStructure(buffer, typeof(Attribute));
                                    Console.WriteLine("AttributeID {0}", AtributeInfo.AttributeID);
                                    Console.WriteLine("Flags {0}", AtributeInfo.Flags);
                                    Console.WriteLine("Value {0}", AtributeInfo.Value);
                                    //if you want HEX values use this line
                                    //Console.WriteLine("Value {0}", BitConverter.ToString(AtributeInfo.VendorData));
                                    //if you want INT values use this line
                                    Console.WriteLine("Data {0}", BitConverter.ToInt32(AtributeInfo.VendorData, 0));
                                }
                                finally
                                {
                                    if (buffer != IntPtr.Zero)
                                    {
                                        Marshal.FreeHGlobal(buffer);
                                    }
                                }
                            }
                            offset += Delta;
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(String.Format("Exception {0} Trace {1}", e.Message, e.StackTrace));
                }
                Console.WriteLine("Press Enter to exit");
                Console.Read();
            }
    

    And remember that if you get anything other than 0, you need to buy a new hard drive!
    Also this code requires UAC elevation, so you need to run the application as an administrator or you will get an exception.

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

Sidebar

Related Questions

Hey guys, I am just trying to pull all the records from my database
Hi I'm trying to pull some javascript on a page off of the page
Just trying to establish whether prototype can do something like $$('#ID a:last').css('color','#111'); Any ideas
I'm trying to get some values off a DB and then putting those values
I am trying to pull at list of resource/database names and IDs from a
I am just getting my feet wet with Qt, I am trying to pull
I am trying to pull a blob from a mysql table and display it
I'm trying to pull a report, (a pie chart or just a list) on
I am trying to pull a project from GitHub, which I am collaborating on,
I'm currently trying to pull the wall from this event page: https://www.facebook.com/event.php?eid=139373546157232 , but

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.