Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting the serial number of the drive
Message
 
À
19/09/2010 21:09:13
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01481909
Message ID:
01481996
Vues:
36
Michel,


Hex ---- decimal
Apply HEX(loDrive.SerialNumber) to see the very same number as in GetDriveInformation

Good Luck

>I have the following two methods which return the serial number of a drive. The second one is an old approach. Both methods return a different serial number. Can anyone explain me what I get two different serial numbers?
>
>
>        ' Get the information on a drive
>        Public Function GetDriveInformation() As Boolean
>            Dim lcSQL As String = ""
>            Dim llSuccess As Boolean = False
>            Dim loQuery As SelectQuery
>            Dim loManagementObject As ManagementObject
>            Dim loSearcher As ManagementObjectSearcher
>
>            lcSQL = "SELECT FreeSpace,QuotasDisabled,VolumeName,VolumeSerialNumber " + _
>             "FROM Win32_LogicalDisk WHERE DeviceID=""" + cProviderName + """"
>
>            Try
>                loQuery = New SelectQuery(lcSQL)
>                loSearcher = New ManagementObjectSearcher(loQuery)
>
>                For Each loManagementObject In loSearcher.Get()
>
>                    ' Free disk space is irrelevant if per user quota's are enabled
>                    If loManagementObject("QuotasDisabled").ToString() <> "true" Then
>                        cVolumeSerialNumber = loManagementObject("VolumeSerialNumber")
>                    End If
>
>                Next
>
>                llSuccess = True
>
>            Catch loError As Exception
>                cError = loError.Message
>            End Try
>
>            Return llSuccess
>        End Function
>
>        Public Function GetDriveSerialNumberWithFileSystemObject() As Boolean
>            Dim llSuccess As Boolean = False
>            Dim loDrive As Object = Nothing
>            Dim loFileSystemObject As Object = Nothing
>
>            Try
>
>                ' Create a FileSystemObject object
>                loFileSystemObject = CreateObject("Scripting.FileSystemObject")
>
>                ' Assign the current drive letter if not specified
>                loDrive = loFileSystemObject.GetDrive(cDrive)
>
>                ' If the drive is ready
>                If loDrive.IsReady Then
>                    cVolumeSerialNumber = Math.Abs(loDrive.SerialNumber)
>                    llSuccess = True
>                Else
>                    cError = cDriveNotReady
>                End If
>
>            Catch loError As Exception
>                cError = loError.Message
>            End Try
>
>            Return llSuccess
>        End Function
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform