Results 1 to 3 of 3

Thread: Hard disk ID

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Location
    Dhaka, Bangladesh
    Posts
    102

    Hard disk ID

    Can I read the ID of my Hard Disk from vb code ?

    If anyone know, plz help me.


    Rajib

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Hard disk ID

    Sorry, this is the wrong section.

    This section is a place where you can post code snippets others may find useful, you want the Classic Visual Basic forum

    And to answer your question try this:

    VB Code:
    1. Private Const DRIVE_CDROM As Long = 5
    2. Private Sub Form_Load()
    3.     MsgBox [b]DriveSerial("C:\")[/b]
    4. End Sub
    5.  
    6. Private Function DriveSerial(strDrive As String) As String
    7.     ' Returns the drive serial number.
    8.     Dim FSO As Object
    9.     Set FSO = CreateObject("Scripting.FileSystemObject")
    10.     If Len(strDrive) > 3 Then
    11.         Exit Sub
    12.     End If
    13.     If (FSO.GetDrive(strDrive).IsReady = True) And (Not GetDriveType(strDrive) = DRIVE_CDROM) Then
    14.         DriveSerial = CStr(FSO.GetDrive(strDrive).SerialNumber)
    15.     Else
    16.         DriveSerial = "Not Available"
    17.     End If
    18. End Property

    And there you go - I've included the DriveSerial wrapper function, it should make things easier when in code

    Cheers,

    RyanJ
    Last edited by Hack; May 24th, 2005 at 05:29 AM.
    My Blog.

    Ryan Jones.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Hard disk ID

    Moved from CodeBank.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width