Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

finding Harddisk's serial number

Posted on 2000-03-06
6
Medium Priority
?
296 Views
Last Modified: 2010-08-05

How to find the Harddisk's serial number through my program in VB.
0
Comment
Question by:SRIVB
  • 4
6 Comments
 
LVL 9

Accepted Solution

by:
Ruchi earned 80 total points
ID: 2588117
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
 
LVL 2

Expert Comment

by:ggilman
ID: 2588567
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
 
LVL 9

Expert Comment

by:Ruchi
ID: 2630764
Hello where are you, SRIVB?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:Ruchi
ID: 2662950
SRIVB, where are you?
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2668291
srivb, any news here?
0
 

Author Comment

by:SRIVB
ID: 2673050
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question