Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I get internal HDD_DETLAIS = SerialNumber, Model, Manufacturer,TotalHeads ...... etc.
Please help me.. Now my problem is my code run ok, but when I insert external HDD or pen drive then showing the last counting device Details please help ....
i want to show only internal HHD device means OS loaded disk "C" drive
Thanks

What I have tried:

VB
Dim HDD_DETLAIS As String
Dim HDD As New ManagementObjectSearcher("select * from Win32_DiskDrive")
For Each HDDDET In HDD.Get
   HDD_DETLAIS = HDDDET("SerialNumber") + 
   "   Model-" + HDDDET("Model") + 
   "   Manufacturer-- " + HDDDET("Manufacturer") 
' + "  TotalHeads  -  " + hd("TotalHeads") '+ "   Signature - " + hd("Signature")
            
    TextBox1.Text = HDD_DETLAIS

Next
Posted
Updated 31-Jul-19 6:49am
v2

1 solution

Simple - look at your code:
VB
For Each HDDDET In HDD.Get
    HDD_DETLAIS = ...
    TextBox1.Text = HDD_DETLAIS
Next
Each time you go round the loop you positively set the textbox content - so when you end the loop you will always show the last item you set info for.

If you have two HDDs, you will always see the second.
If you insert a USB stick, you will see that.

Decide what exactly you want to see, and when you find it in the loop, break out of teh loop by using Exit For
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900