December 03, 2020, 08:38:54 PM

Author Topic: [bb] Drive Volume Information by EOF [ 1+ years ago ]  (Read 474 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Drive Volume Information by EOF [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : Drive Volume Information
Author : EOF
Posted : 1+ years ago

Description : This returns lots of handy info regarding volume information.

Please test and let me know if it reports the right details!

Now you can find out:
Code: [Select]
Volume Name          My Computer etc ...
Type                 Fixed, Floppy ,CD-Rom etc
Serial Number        Device serial number
Flags                Don't know much about these yet
File System          FAT32, NTFS, CDFS, ...
Format               0 or 255 (indicates short (8.3) or long format)


Note1: Throw the declarations into 'Kernel32.decls'
Note2: There is a small delay when checking Floppy Drives. [/i]

Code :
Code: BlitzBasic
  1. ; Volume Information
  2.  
  3. ; !!   place these in 'Kernel32.decls'   !!
  4. ; *****************************************
  5. ; GetDriveType%(drivename$):"GetDriveTypeA"
  6. ; GetVolumeInformation%(Path$,VolNameBuff*,VolLen%,Serial*,MaxComponentLen*,fsFlags*,fsNameBuff*,fsNameLen%):"GetVolumeInformationA"
  7. ; GetLogicalDriveStrings%(bufflen%,buffer*):"GetLogicalDriveStringsA"
  8. ; *****************************************
  9.  
  10.  
  11.  
  12. ; volume details are stored here
  13. Type volumeinfo
  14.         Field driveletter$     ; Drives letter                "A:"  "C:"   "F:"
  15.         Field drivename$       ; Name of device               "My Computer"
  16.         Field drivetype$       ; What type                    "Floppy" "CD-Rom"
  17.         Field serial%          ; Serial number                1234567890
  18.         Field maxcomponentlen% ; long/short name support      8.3  255
  19.         Field flags%           ; associated flags             012345
  20.         Field filesystem$      ; file system used             FAT32 NTFS CDFS
  21. End Type
  22. Global vol.volumeinfo
  23.  
  24. GetVolumeInfo ; fill 'volumeinfo' type with available volumes information
  25.  
  26. Print "Vol     Name                Type          Serial       Flags    FileSystem"
  27. Print "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
  28. For vol=Each volumeinfo
  29.         r$=voldriveletter$+"     "+Left$(voldrivename$+String$(" ",19),19)
  30.         r$=r$+" "+Left$(voldrivetype$+String$(" ",12),12)
  31.         r$=r$+" "+Right$(String$(" ",10)+Str$(volserial),11)+"   "
  32.         r$=r$+Right$("      "+Str$(volflags),6)+"   "+volfilesystem
  33.         Print r$
  34. Next
  35.  
  36. Print
  37. a$=Input$("Done ... RETURN to end")
  38. End
  39.  
  40.  
  41.  
  42. Function GetVolumeInfo()
  43.         ; first, get a list of available volumes  .. A:B:C:F: ...
  44.         vlist=CreateBank(256)
  45.         GetLogicalDriveStrings 255,vlist
  46.         drivelist$=PeekString$(vlist,256)
  47.         FreeBank vlist
  48.         ; run through list of voulumes
  49.         For x=0 To Len(drivelist$)/3-1
  50.                 vol=New volumeinfo
  51.                 voldriveletter$=Mid$(drivelist$,x*3+1,3)
  52.                 voldrivename$="(not available)"
  53.                 Select GetDriveType(voldriveletter$)
  54.                         Case 2 : voldrivetype$= "Removable"
  55.                         Case 3 : voldrivetype$= "Drive Fixed"
  56.                         Case 4 : voldrivetype$= "Remote"
  57.                         Case 5 : voldrivetype$= "Cd-Rom"
  58.                         Case 6 : voldrivetype$= "Ram disk"
  59.                         Default : voldrivetype$= "Unrecognized"
  60.                 End Select
  61.                 vn=CreateBank(256) : sn=CreateBank(4)
  62.                 mcl=CreateBank(4) : flags=CreateBank(4) : fs=CreateBank(256)
  63.                 GetVolumeInformation voldriveletter$,vn,255,sn,mcl,flags,fs,255
  64.                 voldrivename$=PeekString$(vn,256)
  65.                 If voldrivename$="" Then voldrivename$="(not available)"
  66.                 volserial=PeekInt(sn,0)
  67.                 volmaxcomponentlen=PeekInt(mcl,0)
  68.                 volflags=PeekInt(flags,0)
  69.                 volfilesystem=PeekString$(fs,256)
  70.                 ; free the banks
  71.                 FreeBank sn : FreeBank mcl : FreeBank flags
  72.                 FreeBank vn : FreeBank fs
  73.         Next
  74. End Function
  75.  
  76. ; build and return a string of characters from a bank
  77. Function PeekString$(bank,numbytes)
  78.         Local a$=""
  79.         For pos=0 To numbytes-1
  80.                 byte=PeekByte(bank,pos)
  81.                 If byte<>0 Then a$=a$+Chr$(byte)
  82.         Next
  83.         Return a$
  84. End Function


Comments :


David Boudreau(Posted 1+ years ago)

 For BlitzPlus- In the middle of this code, join the first 2 lines of:Printa$=Input$("Done ... RETURN to end")Endto:Print a$=Input$("Done ...Return to end")Endor, at least in BlitzPlus, you need to do this.


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal