• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 300
  • Last Modified:

finding Harddisk's serial number


How to find the Harddisk's serial number through my program in VB.
0
SRIVB
Asked:
SRIVB
  • 4
1 Solution
 
RuchiCommented:
Private Declare Function GetVolumeInformation Lib _
"kernel32.dll" Alias "GetVolumeInformationA" (ByVal _
lpRootPathName As String, ByVal lpVolumeNameBuffer As _
String, ByVal nVolumeNameSize As Integer, _
lpVolumeSerialNumber As Long, lpMaximumComponentLength _
As Long, lpFileSystemFlags As Long, ByVal _
lpFileSystemNameBuffer As String, ByVal _
nFileSystemNameSize As Long) As Long

Function GetSerialNumber(strDrive As String) As Long
Dim SerialNum As Long
Dim Res As Long
Dim Temp1 As String
Dim Temp2 As String
Temp1 = String$(255, Chr$(0))
Temp2 = String$(255, Chr$(0))

Res = GetVolumeInformation(strDrive, Temp1, _
Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2))

GetSerialNumber = SerialNum

End Function

Private Sub cmdSerial_Click()
Call MsgBox(GetSerialNumber("C:\"))
End Sub
0
 
ggilmanCommented:
Tried Ruchi's answer because I was curious too and works well. Only comment I have is that if you want to compare it to what you get at the command prompt by typing "dir", use the hex function:

Call MsgBox(Hex(GetSerialNumber("C:\")))
0
 
RuchiCommented:
Hello where are you, SRIVB?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
RuchiCommented:
SRIVB, where are you?
0
 
RuchiCommented:
srivb, any news here?
0
 
SRIVBAuthor Commented:
Sorry for the delay..

I worked out your answer, but it only gives the volume serial number.  But I want to find the physical id of the hard disk which was created by the manufacturer of the disk.
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now