|
|
 |
| 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.
|
 |

May 4th, 2007, 12:25 AM
|
|
Registered User
|
|
Join Date: May 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

May 4th, 2007, 12:37 AM
|
|
Wrox Author
Points: 12,827, Level: 49 |
|
|
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,029
Thanks: 1
Thanked 42 Times in 42 Posts
|
|
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
================================================== =========
|

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
|
|
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
|

June 20th, 2007, 07:44 PM
|
|
Registered User
|
|
Join Date: Mar 2007
Location: , , Netherlands.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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;
}
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |