SHARE
TWEET

Тест кода PureBasic

AZJIO Mar 19th, 2019 (edited) 160 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Получение номера диска и раздела, из буквы раздела
  2. Procedure.s DriveGetNumber(DriveLetter$)
  3.     Protected DriveInfo.STORAGE_DEVICE_NUMBER, Nul , Ret$="?:?", hDevice
  4.     hDevice = CreateFile_("\\.\" + DriveLetter$, 0, 0, 0, #OPEN_EXISTING, #FILE_ATTRIBUTE_NORMAL, #NUL)
  5.     If hDevice
  6.         If DeviceIoControl_(hDevice,#IOCTL_STORAGE_GET_DEVICE_NUMBER, 0, 0, DriveInfo, SizeOf(STORAGE_DEVICE_NUMBER), @Nul,  #NUL)
  7.             Ret$=Str(DriveInfo\DeviceNumber) + ":" + Str(DriveInfo\PartitionNumber)
  8.         EndIf
  9.         CloseHandle_(hDevice)
  10.     EndIf
  11.     ProcedureReturn Ret$
  12. EndProcedure
  13.  
  14.  
  15. Define.l Serial, type, disk_mask
  16. Define.s Drive, FileSystem, VolName, Letter, NumDsk
  17. Define.q total_bytes, StartTime
  18. FileSystem = Space(256)
  19. VolName= Space(256)
  20. Letter = "C"
  21. Drive=Letter+":\"
  22.  
  23. StartTime=ElapsedMilliseconds()
  24. disk_mask = GetLogicalDrives_()
  25. Debug Str(ElapsedMilliseconds()-StartTime) + " мсек - время GetLogicalDrives_ "
  26.  
  27. StartTime=ElapsedMilliseconds()
  28. Type = GetDriveType_(Drive)
  29. Debug Str(ElapsedMilliseconds()-StartTime) + " мсек - время GetDriveType_ "
  30.  
  31. StartTime=ElapsedMilliseconds()
  32. GetDiskFreeSpaceEx_(Drive, 0, @total_bytes, 0)
  33. Debug Str(ElapsedMilliseconds()-StartTime) + " мсек - время GetDiskFreeSpaceEx_ "
  34.  
  35. StartTime=ElapsedMilliseconds()
  36. GetVolumeInformation_(@Drive, @VolName, 255, @Serial, 0, 0, @FileSystem, 255)
  37. Debug Str(ElapsedMilliseconds()-StartTime) + " мсек - время GetVolumeInformation_ "
  38.  
  39. StartTime=ElapsedMilliseconds()
  40. NumDsk = DriveGetNumber(Letter + ":")
  41. Debug Str(ElapsedMilliseconds()-StartTime) + " мсек - время DriveGetNumber "
  42.  
  43. Debug #CRLF$ + "Проверяем что работает" + #CRLF$
  44. Debug "disk_mask = " + ReverseString(RSet(Bin(disk_mask, #PB_Long), 32, "0"))
  45. Debug "total_bytes = " + Str(total_bytes / 1024 / 1024) ; Мб
  46. Debug "Type = " + Str(Type)
  47. Debug "FileSystem, VolName, Serial = " + FileSystem + " - " + VolName + " - " + Str(Serial)
  48. Debug "NumDsk = " + NumDsk
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top