Get hard drive serial number vba

broken image
broken image

'1) Check whether the drive is removal or CD-Rom or not If (Not DiskFound) And (strDrive 'all') Then MsgBox 'No drive with this letter found!' 'Check whether there is a drive with the letter the user entered

broken image

StrSave = Right$(strSave, Len(strSave) - InStr(1, strSave, Chr$(0))) MsgBox 'This isn't a removal or CD-Rom drive' MsgBox 'There is a Disk in drive: ' & strDriveNameĮlseIf (strDrive + ':\') = strDriveName Then MsgBox 'No Disk in drive: ' & strDriveName StrDriveName = Left$(strSave, InStr(1, strSave, Chr$(0)) - 1) If Left$(strSave, InStr(1, strSave, Chr$(0))) = Chr$(0) Then Exit For Ret& = GetLogicalDriveStrings(255, strSave) Public Function CheckNow(strDrive As String) 'InPut: the letter of the drive to check it or the string 'all' to check for all drives Private Declare Function GetLogicalDriveStrings Lib 'kernel32' Alias 'GetLogicalDriveStringsA' (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long Private Declare Function GetDriveType Lib 'kernel32' Alias 'GetDriveTypeA' (ByVal nDrive As String) As Long '''try to run this code Const CheckDrive_NotRem = 0

broken image