p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > C# and C > C# 2005 > C# 2005
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 4th, 2007, 12:25 AM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hard Disk Serial Number

Could anybody please help me with a piece of code to get hard disk's serial number using C#, not volume serial number, actual number that manufactures give to hard disks.


Thanks in Advance
Preetha


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old May 4th, 2007, 12:37 AM
Wrox Author
Points: 12,827, Level: 49
Points: 12,827, Level: 49 Points: 12,827, Level: 49 Points: 12,827, Level: 49
Activity: 15%
Activity: 15% Activity: 15% Activity: 15%
 
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,029
Thanks: 1
Thanked 42 Times in 42 Posts
Send a message via AIM to dparsons
Default

You will need to query WMI for this. (From WMI you can get both the volume and manuf. serial number)

A simple google search on this should net you plenty of examples.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old May 10th, 2007, 08:58 AM
Authorized User
 
Join Date: May 2007
Location: Bangalore, KA, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi , u can WMI query then u can get the resule.

Please chk in ; www.codeproject.com. there u can get lot idea for WMI ...


With Regards,
Muralidharan.D
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old June 20th, 2007, 07:44 PM
Registered User
 
Join Date: Mar 2007
Location: , , Netherlands.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

this can be done in three simple steps:

1. add refrence to System.Management
2. add
Code:
 using System.Management
at the top of your document
3. add the code

Code:
string[] HdSerialNumber;

            ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");

            int countHD = 0;

            foreach (ManagementObject mo in mos.Get())
            {
                countHD += 1;
            }

            HdSerialNumber = new string[countHD];

            int i = 0;

            foreach (ManagementObject mo in mos.Get())
            {
                if (mo["SerialNumber"].ToString() != null)
                {
                    HdSerialNumber[i] = mo["SerialNumber"].ToString();
                }
                else
                {
                    HdSerialNumber[i] = "";
                }
                i += 1;
            }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hard Disk Serial Number Asmatullah VB.NET 2002/2003 Basics 1 December 18th, 2007 04:26 PM
Serial Number of the Hard Disk ivanlaw Assembly Language 0 July 15th, 2007 11:15 PM
how to get hard disk serial number in c# imran_mani .NET Framework 1.x 0 May 7th, 2007 04:45 AM
Hard disk serial number alexjiju VS.NET 2002/2003 1 February 3rd, 2007 02:50 PM
How to retreive Hard disk serial no gkrishn01 Java Espanol 0 December 10th, 2004 05:35 AM



All times are GMT -4. The time now is 05:03 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc