Advertisement
sroller

Ruby: get drives on Windows

Apr 4th, 2017
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.31 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. require 'win32/api'
  4. include Win32
  5.  
  6. get_logical_drive_strings = API.new('GetLogicalDriveStrings', 'IP', 'I')
  7.  
  8. BUFLEN = 260
  9. buf = 0.chr * BUFLEN
  10.  
  11. rc = get_logical_drive_strings.call(BUFLEN, buf)
  12. if (0..BUFLEN) === rc
  13.     puts buf[0..rc-1].split("\x00")
  14. else
  15.     puts "buffer too small"
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement