GetDriveInfo – Drive serial number and other data

GetDriveInfo – Drive serial number and other data

Private Declare Function GetVolumeInformation& Lib "kernel32" Alias _    "GetVolumeInformationA" (ByVal lpRootPathName As String, _    ByVal pVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, _    lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, _    lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, _    ByVal nFileSystemNameSize As Long)Const MAX_PATH = 260Const FILE_CASE_SENSITIVE_SEARCH = &H1Const FILE_CASE_PRESERVED_NAMES = &H2Const FILE_UNICODE_ON_DISK = &H4Const FILE_PERSISTENT_ACLS = &H8Const FILE_FILE_COMPRESSION = &H10Const FILE_VOLUME_IS_COMPRESSED = &H8000' return volume name, serial number and file system (eg "FAT") for a given drive' it fails with removable drives if the disk isn't in place' the FileSystemFlags argument is a combination of the FILE_* constats' (see MSDN for additional information)'' you can specify an UNC for the drive name ' (e.g."\MyServerMyShare as \MyServerMyShare"' Under Windows95/98 the serial number of network drives isn't returned'' Returns True if all information has been retrieved successfullyFunction GetDriveInfo(ByVal DriveName As String, Optional VolumeName As String, _    Optional SerialNumber As Long, Optional FileSystem As String, _    Optional FileSystemFlags As Long) As Boolean        Dim ignore As Long        ' if it isn't a UNC path, enforce the correct format    If InStr(DriveName, "\") = 0 Then        DriveName = Left$(DriveName, 1) & ":"    End If        ' prepare receiving buffers    SerialNumber = 0    FileSystemFlags = 0    VolumeName = String$(MAX_PATH, 0)    FileSystem = String$(MAX_PATH, 0)        ' The API function return a non-zero value if successful    GetDriveInfo = GetVolumeInformation(DriveName, VolumeName, Len(VolumeName), _        SerialNumber, ignore, FileSystemFlags, FileSystem, Len(FileSystem))    ' drop characters in excess    VolumeName = Left$(VolumeName, InStr(VolumeName, vbNullChar) - 1)    FileSystem = Left$(FileSystem, InStr(FileSystem, vbNullChar) - 1)    End Function

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of