Solved

finding Harddisk's serial number

Posted on 2000-03-06
6
287 Views
Last Modified: 2010-08-05

How to find the Harddisk's serial number through my program in VB.
0
Comment
Question by:SRIVB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Script Host failed (Access is denied.) error 6 478
Run code from text file in vb 1 103
Hide vba in gp 7 127
adding "ungroup sheets" to existing vbs code 5 75
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

751 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