Solved

finding Harddisk's serial number

Posted on 2000-03-06
6
251 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 20 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now