943,083 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Feb 9th, 2010
0

HDD Serial Number in VB. Please

Expand Post »
Please tell me How can i get HDD serial number in VB
Last edited by rahulmpatki; Feb 9th, 2010 at 11:36 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rahulmpatki is offline Offline
5 posts
since Feb 2010
Feb 9th, 2010
0
Re: HDD Serial Number
Welcome rahul,

With a quick search with one of your friends (yahoo, google, ask, answers, bing) you could find this information... like this search...

http://search.yahoo.com/search?p=vb6...8&fr=yfp-t-701



Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009
Feb 9th, 2010
0
Re: HDD Serial Number
this code show c drive serial number
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Form_Load()
  2.  
  3. 'Show drive serial number for the current drive
  4. MsgBox " Drive serial number for " & Left(App.Path, 1) & ": " & GetDriveSerialNumber
  5. End
  6.  
  7. End Sub
  8. Public Function GetDriveSerialNumber(Optional ByVal DriveLetter As String) As Long
  9.  
  10. Dim fso As Object, Drv As Object
  11.  
  12. 'Create a FileSystemObject object
  13. Set fso = CreateObject("Scripting.FileSystemObject")
  14.  
  15. 'Assign the current drive letter if not specified
  16. If DriveLetter <> "" Then
  17. Set Drv = fso.GetDrive(DriveLetter)
  18. Else
  19. Set Drv = fso.GetDrive(fso.GetDriveName(App.Path))
  20. End If
  21.  
  22. With Drv
  23. If .IsReady Then
  24. DriveSerial = Abs(.SerialNumber)
  25. Else '"Drive Not Ready!"
  26. DriveSerial = -1
  27. End If
  28. End With
  29.  
  30. 'Clean up
  31. Set Drv = Nothing
  32. Set fso = Nothing
  33.  
  34. GetDriveSerialNumber = DriveSerial
  35.  
  36. End Function
Reputation Points: 14
Solved Threads: 78
Practically a Posting Shark
abu taher is offline Offline
835 posts
since Jul 2008
Feb 10th, 2010
0
Re: HDD Serial Number
'''try to run this code

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. Const CheckDrive_NotRem = 0
  3. Const CheckDrive_RemAndFound = 1
  4. Const CheckDrive_RemAndNotFound = 2
  5. Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
  6. Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
  7.  
  8.  
  9. 'InPut: the letter of the drive to check it or the string "all" to check for all drives
  10. Public Function CheckNow(strDrive As String)
  11.  
  12. Dim strSave As String
  13. Dim strDriveName As String
  14. Dim Res, keer, DiskFound
  15.  
  16. 'Create a buffer to store all the drives
  17. strSave = String(255, Chr$(0))
  18. 'Get all the drives
  19. ret& = GetLogicalDriveStrings(255, strSave)
  20.  
  21. 'Extract the drives from the buffer
  22. For keer = 1 To 100
  23. If Left$(strSave, InStr(1, strSave, Chr$(0))) = Chr$(0) Then Exit For
  24. strDriveName = Left$(strSave, InStr(1, strSave, Chr$(0)) - 1)
  25. 'Check the drive for type and diskettes
  26. If strDrive = "all" Then
  27. Res = CheckDrive(strDriveName)
  28. If Res = CheckDrive_RemAndNotFound Then
  29. MsgBox "No Disk in drive: " & strDriveName
  30. ElseIf Res = CheckDrive_RemAndFound Then
  31. MsgBox "There is a Disk in drive: " & strDriveName
  32. End If
  33. ElseIf (strDrive + ":\") = strDriveName Then
  34. Res = CheckDrive(strDriveName)
  35. If Res = CheckDrive_RemAndNotFound Then
  36. MsgBox "No Disk in drive: " & strDriveName
  37. ElseIf Res = CheckDrive_RemAndFound Then
  38. MsgBox "There is a Disk in drive: " & strDriveName
  39. ElseIf Res = CheckDrive_NotRem Then
  40. MsgBox "This isn't a removal or CD-Rom drive"
  41. End If
  42. DiskFound = True
  43. Exit For
  44. End If
  45. strSave = Right$(strSave, Len(strSave) - InStr(1, strSave, Chr$(0)))
  46. Next keer
  47.  
  48. 'Check whether there is a drive with the letter the user entered
  49. If (Not DiskFound) And (strDrive <> "all") Then MsgBox "No drive with this letter found!"
  50. End Function
  51.  
  52. ''''''''''''''''''''''''
  53. 'Task:
  54. '1) Check whether the drive is removal or CD-Rom or not
  55. '2) Check if there is a disk in the drive
  56. 'The idea depends on changing the directory to the drive
  57. 'path then check: if an error happens that means the program
  58. 'can't change the directory to the path of the disk.
  59. 'Consequently, there is no disk, and the function returns
  60. '
  61. 'OutPut of CheckDrive:
  62. ' 0 = The drive isn't removal or CD-Rom
  63. ' 1 = There is a Disk in the drive
  64. ' 2 = There is no Disk in the drive
  65. ''''''''''''''''''''''''
  66.  
  67. Function CheckDrive(strDrive As String) As Integer
  68. On Error GoTo errhandler
  69. Select Case GetDriveType(strDrive)
  70. Case 2 ' Removal
  71. ChDir strDrive
  72. CheckDrive = CheckDrive_RemAndFound ' The drive is removal and there is a disk
  73. Exit Function
  74. Case 5 ' CD-Rom drive
  75. ChDir strDrive
  76. CheckDrive = CheckDrive_RemAndFound ' The drive is CD-Rom and there is a disk
  77. Exit Function
  78. End Select
  79.  
  80. Exit Function
  81.  
  82. errhandler:
  83. 'there isn't a Disk in the drive
  84. If Err.Number = 75 Then CheckDrive = 2 'Path/access error
  85.  
  86. End Function
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rahul300 is offline Offline
1 posts
since Feb 2010
Feb 10th, 2010
0
Re: HDD Serial Number
Click to Expand / Collapse  Quote originally posted by rahul300 ...
'''try to run this code

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. Const CheckDrive_NotRem = 0
  3. Const CheckDrive_RemAndFound = 1
  4. Const CheckDrive_RemAndNotFound = 2
  5. Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
  6. Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
  7.  
  8.  
  9. 'InPut: the letter of the drive to check it or the string "all" to check for all drives
  10. Public Function CheckNow(strDrive As String)
  11.  
  12. Dim strSave As String
  13. Dim strDriveName As String
  14. Dim Res, keer, DiskFound
  15.  
  16. 'Create a buffer to store all the drives
  17. strSave = String(255, Chr$(0))
  18. 'Get all the drives
  19. ret& = GetLogicalDriveStrings(255, strSave)
  20.  
  21. 'Extract the drives from the buffer
  22. For keer = 1 To 100
  23. If Left$(strSave, InStr(1, strSave, Chr$(0))) = Chr$(0) Then Exit For
  24. strDriveName = Left$(strSave, InStr(1, strSave, Chr$(0)) - 1)
  25. 'Check the drive for type and diskettes
  26. If strDrive = "all" Then
  27. Res = CheckDrive(strDriveName)
  28. If Res = CheckDrive_RemAndNotFound Then
  29. MsgBox "No Disk in drive: " & strDriveName
  30. ElseIf Res = CheckDrive_RemAndFound Then
  31. MsgBox "There is a Disk in drive: " & strDriveName
  32. End If
  33. ElseIf (strDrive + ":\") = strDriveName Then
  34. Res = CheckDrive(strDriveName)
  35. If Res = CheckDrive_RemAndNotFound Then
  36. MsgBox "No Disk in drive: " & strDriveName
  37. ElseIf Res = CheckDrive_RemAndFound Then
  38. MsgBox "There is a Disk in drive: " & strDriveName
  39. ElseIf Res = CheckDrive_NotRem Then
  40. MsgBox "This isn't a removal or CD-Rom drive"
  41. End If
  42. DiskFound = True
  43. Exit For
  44. End If
  45. strSave = Right$(strSave, Len(strSave) - InStr(1, strSave, Chr$(0)))
  46. Next keer
  47.  
  48. 'Check whether there is a drive with the letter the user entered
  49. If (Not DiskFound) And (strDrive <> "all") Then MsgBox "No drive with this letter found!"
  50. End Function
  51.  
  52. ''''''''''''''''''''''''
  53. 'Task:
  54. '1) Check whether the drive is removal or CD-Rom or not
  55. '2) Check if there is a disk in the drive
  56. 'The idea depends on changing the directory to the drive
  57. 'path then check: if an error happens that means the program
  58. 'can't change the directory to the path of the disk.
  59. 'Consequently, there is no disk, and the function returns
  60. '
  61. 'OutPut of CheckDrive:
  62. ' 0 = The drive isn't removal or CD-Rom
  63. ' 1 = There is a Disk in the drive
  64. ' 2 = There is no Disk in the drive
  65. ''''''''''''''''''''''''
  66.  
  67. Function CheckDrive(strDrive As String) As Integer
  68. On Error GoTo errhandler
  69. Select Case GetDriveType(strDrive)
  70. Case 2 ' Removal
  71. ChDir strDrive
  72. CheckDrive = CheckDrive_RemAndFound ' The drive is removal and there is a disk
  73. Exit Function
  74. Case 5 ' CD-Rom drive
  75. ChDir strDrive
  76. CheckDrive = CheckDrive_RemAndFound ' The drive is CD-Rom and there is a disk
  77. Exit Function
  78. End Select
  79.  
  80. Exit Function
  81.  
  82. errhandler:
  83. 'there isn't a Disk in the drive
  84. If Err.Number = 75 Then CheckDrive = 2 'Path/access error
  85.  
  86. End Function
''thanks but i want hard disk serial number your code is for drive serial number or volume number.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rahulmpatki is offline Offline
5 posts
since Feb 2010
Feb 10th, 2010
0

HDD serial number not volume number of drive please

''thanks but i want hard disk serial number your code is for drive serial number or volume number.

i need code for Hard disk serial number which is not changed after format hard disk.

HDD serial number is displayed in cmos setup also
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rahulmpatki is offline Offline
5 posts
since Feb 2010
Feb 10th, 2010
0
Re: HDD Serial Number
try this.
Attached Files
File Type: zip PROJECT.zip (51.8 KB, 275 views)
Reputation Points: 14
Solved Threads: 78
Practically a Posting Shark
abu taher is offline Offline
835 posts
since Jul 2008
Feb 11th, 2010
0

HDD Serial Number in VB. Please

'' ABU TAHER again thanks but i want hard disk serial number your code is for drive serial number or volume number.
my mailID rajnew.300@rediffmail.com

i need code for Hard disk serial number which is not changed after format hard disk.
my mailID rajnew.300@rediffmail.com
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rahulmpatki is offline Offline
5 posts
since Feb 2010
Feb 13th, 2010
0
Re: HDD Serial Number
ok. please try it again.
Attached Files
File Type: zip HDDSerial.zip (11.0 KB, 234 views)
Reputation Points: 14
Solved Threads: 78
Practically a Posting Shark
abu taher is offline Offline
835 posts
since Jul 2008
Feb 13th, 2010
0

HDD Serial Number in VB. Please

I need HDD serial Number
in this project after selecting combo box (Slave or master disk) no result display.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rahulmpatki is offline Offline
5 posts
since Feb 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Calculate Average assistance needed please
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Date time





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC