Results 1 to 5 of 5

Thread: Windows Numbers

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ...

    If I needed something like that...
    I'd get the hard drive serial number and store it in the window's registry

  2. #2
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    Hmm

    Do you know the API to do that(technically I could check my api list at home...but I'm not at home)
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ....

    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 Command1_Click()
    'Replace 'c:\' with the drive you want to find his serial number
    Call MsgBox(GetSerialNumber("c:\"))
    End Sub


  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    ..

    actually, this says a bit more... Got i a while back

    The GetVolumeInformation API call is used to retrieve information about hard drives, floppy drives, and even CD-ROM drives. Notice how your Windows CD player can recognize which CD is inserted? It is using the serial number of the CD-ROM (obtained with this API call) to make this determination. Just substitute the drive letter where it currently says "F:\" and you can check on any of your drives.

    The code that follows will return the serial number (as a long), as well as the volume name and volume type, such as FAT. However, the text in the returned strings is ended with a null character - chr$(0). That's the reason for the InStr call -- it only shows the portion of the string up to the null character. If you don't do that, the DLL showing the MsgBox interprets the null character as the end of line and no further text is displayed.

    Option Explicit
    Private Declare Function GetVolumeInformation _
    Lib "kernel32" Alias "GetVolumeInformationA" _
    (ByVal lpRootPathName As String, _
    ByVal lpVolumeNameBuffer As String, _
    ByVal nVolumeNameSize As Long, _
    lpVolumeSerialNumber As Long, _
    lpMaximumComponentLength As Long, _
    lpFileSystemFlags As Long, _
    ByVal lpFileSystemNameBuffer As String, _
    ByVal nFileSystemNameSize As Long) As Long


    Private Sub cmdTest_Click()
    Dim iSerialNum As Long
    Dim sVolumeLabel As String
    Dim sVolumeType As String
    Dim iRetVal As Long
    sVolumeLabel = Space(255)
    sVolumeType = Space(255)
    iRetVal = GetVolumeInformation("f:\", _
    sVolumeLabel, Len(sVolumeLabel), _
    iSerialNum, _
    0, 0, _
    sVolumeType, Len(sVolumeType))

    MsgBox "Disk Serial Number: " & iSerialNum & vbCrLf _
    & "Volume Type: " & Left$(sVolumeType, InStr(sVolumeType, Chr$(0)) - 1) & vbCrLf _
    & "Volume Label: " & Left$(sVolumeLabel, InStr(sVolumeLabel, Chr$(0)) - 1)

    End Sub

    Written by Eric Smith on 12/3/97.


  5. #5
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    thanx guys. I appreciate it

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