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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:21:19+00:00 2026-06-07T21:21:19+00:00

I have a C#.net Windows form Application with SQL Server. My application use in

  • 0

I have a C#.net Windows form Application with SQL Server. My application use in Multiple user by local Network. Now I need to find Hard disk Serial Number which hard disk installed sql server (Note: By Using C#.net Application Data source ).

How can i find Hard disk Serial number throw by application data source?

  • 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-06-07T21:21:20+00:00Added an answer on June 7, 2026 at 9:21 pm

    This might be useful

    using System;
    using System.Management;
    using System.Collections;
    
    namespace WmiControl
    {
        public class WMI
        {
            public bool GetDiskSerial(string Computername)
            {
    
                try
                {
                    ManagementScope scope = new ManagementScope(@"\\" + Computername + @"\root\cimv2");
                    scope.Connect();
                    ArrayList hdCollection;
                    ManagementObjectSearcher searcher;
                    if (GetDiskDrive(scope, out hdCollection, out searcher) || GetDiskSerial(scope, hdCollection, ref searcher))
                        return true;
                    else 
                        return false;
                }
                catch (ManagementException)
                {
                    return false;
                }
    
            }
    
            private bool GetDiskSerial(ManagementScope scope, ArrayList hdCollection, ref ManagementObjectSearcher searcher)
            {
                try
                {
    
    
                    ObjectQuery query1 = new ObjectQuery("SELECT * FROM Win32_PhysicalMedia");
    
                    searcher = new ManagementObjectSearcher(scope, query1);
                    int i = 0;
                    string sDiskSerial = "";
                    foreach (ManagementObject wmi_HD in searcher.Get())
                    {
                        // get the hard drive from collection
                        // using index
                        if (i < hdCollection.Count)
                        {
                            HardDrive hd = (HardDrive)hdCollection[i];
                            if (wmi_HD["SerialNumber"] == null)
                                hd.SerialNo = "";
                            else
                                hd.SerialNo = wmi_HD["SerialNumber"].ToString();
                        }
                        ++i;
                    }
                    foreach (HardDrive hd in hdCollection)
                    {
                        if (!String.IsNullOrEmpty(hd.SerialNo))
                        {
                            sDiskSerial = hd.SerialNo;
                            break;
                        }
                    }
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
    
            private bool GetDiskDrive(ManagementScope scope, out ArrayList hdCollection, out ManagementObjectSearcher searcher)
            {
                try
                {
                    ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_DiskDrive");
                    hdCollection = new ArrayList();
                    searcher = new ManagementObjectSearcher(scope, query);
                    foreach (ManagementObject wmi_HD in searcher.Get())
                    {
                        HardDrive hd = new HardDrive();
                        hd.Model = wmi_HD["Model"].ToString();
                        hd.Type = wmi_HD["InterfaceType"].ToString();
                        hdCollection.Add(hd);
                        return true;
                    }
                    return true;
                }
                catch (Exception)
                {
                    hdCollection = null;
                    searcher = null;
                    return false;
                }
            }
        }
        class HardDrive
        {
            private string model = null;
            private string type = null;
            private string serialNo = null;
            public string Model
            {
                get { return model; }
                set { model = value; }
            }
            public string Type
            {
                get { return type; }
                set { type = value; }
            }
            public string SerialNo
            {
                get { return serialNo; }
                set { serialNo = value; }
            }
        }
    }
    

    See here for more info

    You might want also to study CLR

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

Sidebar

Related Questions

Im using c# .net windows form application. i have a SQL database with 5
Im using c# .net windows form application. I have many databases created using sql
I have developed a Windows application in .NET which uses a SQL Server database
I have a simple .net windows form which inserts user input into sql database.
Im using c# .net windows form application. I have loaded names of all the
Im using c# .net windows application form. I have created many databases with many
Windows form application(.Net 3.5) I have a textbox and a button on the form.
Im using c# .net , windows form application. I have a XML file which
I have a windows forms application in .NET 3.5. There's one form with 20
net windows form application. I have a combo box and a text box and

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.