Get the Drive Serial Number

You can get the serial number of your hard drive, floppy disk, or CD-ROM easily without any additional ActiveX component. First, start a VB project, add a standard module, and place a Command Button control on the form:

'-- Module codePrivate Declare Function GetVolumeInformation _	Lib "kernel32" Alias "GetVolumeInformationA" _	(ByVal lpRootPathName As String, _	ByVal pVolumeNameBuffer As String, _	ByVal nVolumeNameSize As Long, _	lpVolumeSerialNumber As Long, _	lpMaximumComponentLength As Long, _	lpFileSystemFlags As Long, _	ByVal lpFileSystemNameBuffer As String, _	ByVal nFileSystemNameSize As Long) As LongPublic Function GetSerialNumber( _	ByVal sDrive As String) As Long	If Len(sDrive) Then		If InStr(sDrive, "\") = 1 Then			' Make sure we end in backslash for UNC			If Right$(sDrive, 1) <> "" Then				sDrive = sDrive & ""			End If		Else			' If not UNC, take first letter as drive			sDrive = Left$(sDrive, 1) & ":"		End If	Else		' Else just use current drive		sDrive = vbNullString	End If		' Grab S/N -- Most params can be NULL	Call GetVolumeInformation( _		sDrive, vbNullString, 0, GetSerialNumber, _		ByVal 0&, ByVal 0&, vbNullString, 0)End Function'-- Form codePrivate Sub Command1_Click()	Dim Drive As String	Drive = InputBox("Enter drive for checking SN")	MsgBox Hex$(GetSerialNumber(Drive))End Sub
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS