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

HDD No

Hi
 
  Is there anyway of extracting Hard Disk Identification No, CDR No and Floppy Disk No
0
NANJU
Asked:
NANJU
  • 3
1 Solution
 
Erick37Commented:
From:
http://www.vb-world.net/tips/tip29.html

'Declarations

'Copy this code into the declarations section of the project.

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

'Code

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

'Use

'An example of using the above function:

Call MsgBox GetSerialNumber("C:")
'This will bring up a message box with the serial number of the C drive.
0
 
Erick37Commented:
Usage correction:

Private Sub Command1_Click()
MsgBox Hex(GetSerialNumber("c:\"))
End Sub
0
 
Erick37Commented:
Or if you want the NNNN-NNNN format:

Private Sub Command1_Click()
MsgBox Format(Hex(GetSerialNumber("c:\")), "&&&&-&&&&")
End Sub
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

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