Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. Dim DevType As Integer = Runtime.InteropServices.Marshal.ReadInt32(M.LParam, 4)
  2.  
  3.  
  4. If DevType = DBT_DEVTYP_VOLUME Then
  5.  
  6. Dim Vol As New DEV_BROADCAST_VOLUME
  7.  
  8. Vol = Runtime.InteropServices.Marshal.PtrToStructure(M.LParam, GetType(DEV_BROADCAST_VOLUME))
  9.  
  10. If Vol.Dbcv_Flags = 0 Then
  11.  
  12. For i As Integer = 0 To 20
  13.  
  14. If Math.Pow(2, i) = Vol.Dbcv_Unitmask Then
  15. Dim usb = From getInfo In System.IO.DriveInfo.GetDrives
  16. Dim d As IO.DriveInfo
  17. For Each d In usb
  18. If d.IsReady = True AndAlso d.DriveType = IO.DriveType.Removable Then
  19. unidades.Items.Add(d.Name & d.VolumeLabel).ToString()
  20. End If
  21. Next
  22.  
  23. Exit For
  24.  
  25. End If
  26.  
  27. Next
  28.  
  29.  
  30.  
  31. End If
  32.  
  33. End If
  34.  
  35. Dim DevType As Integer = Runtime.InteropServices.Marshal.ReadInt32(M.LParam, 4)
  36.  
  37. If DevType = DBT_DEVTYP_VOLUME Then
  38.  
  39. Dim Vol As New DEV_BROADCAST_VOLUME
  40.  
  41. Vol = Runtime.InteropServices.Marshal.PtrToStructure(M.LParam, GetType(DEV_BROADCAST_VOLUME))
  42.  
  43. If Vol.Dbcv_Flags = 0 Then
  44.  
  45. For i As Integer = 0 To 20
  46.  
  47. If Math.Pow(2, i) = Vol.Dbcv_Unitmask Then
  48.  
  49. Dim usb = From getInfo In System.IO.DriveInfo.GetDrives
  50. Dim d As IO.DriveInfo
  51. For Each d In usb
  52. If d.IsReady = False AndAlso d.DriveType = IO.DriveType.Removable Then
  53. unidades.Items.Remove(d.Name & d.VolumeLabel & usb.ToString)
  54. End If
  55. Next
  56.  
  57. Exit For
  58.  
  59. End If
  60.  
  61. Next
  62.  
  63. End If
  64.  
  65. End If
  66.  
  67. End Select
  68.  
  69. End If
  70.  
  71. MyBase.WndProc(M)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement