From: Damphyr Date: 2003-07-26T08:21:38+09:00 Subject: Re: Quick way to find all drives in a windows box Bill Kelly wrote: > Here's one way: > > # define the call: > >>>require 'Win32API' > > => true > >>>GetLogicalDriveStrings = Win32API.new("kernel32", "GetLogicalDriveStrings", ['L', 'P'], 'L') > > => # > > # create a buffer to hold the result and execute the call: > >>>buf = "\0" * 1024 >>>len = GetLogicalDriveStrings.call(buf.length, buf) > > => 40 > # if successful, is now the length of the null-terminated > # drive names appended into the buffer.... (if failed, will > # be zero, or some size exceeding the length we passed in) > > # looking at the raw data... > >>>buf[0..len] > > => "A:\\\000C:\\\000D:\\\000E:\\\000F:\\\000G:\\\000M:\\\000P:\\\000T:\\\000Z:\\\000\000" > > # split drive strings into array: > >>>buf[0..len].split("\0") > > => ["A:\\", "C:\\", "D:\\", "E:\\", "F:\\", "G:\\", "M:\\", "P:\\", "T:\\", "Z:\\"] > > > Hope this helps, Well, yes and no :) I was hoping to avoid Win32API but I'll settle for that now. Thanks, V.- ____________________________________________________________________ http://www.freemail.gr - ������ �������� ������������ ������������. http://www.freemail.gr - free email service for the Greek-speaking.