From: Shashank Date Date: 2003-03-18T13:49:49+09:00 Subject: Re: name or label of a device/drive (os: win2000) # Working code: try it with a formatted floppy disk in the A:\ drive # Getting the serial number is left as an exercise ;-) require 'Win32API' STDOUT.sync = true MAX_PATH = 260 def getVolInfo(buf) print buf+'> ' params = [ 'P', #LPCTSTR lpRootPathName, 'P', #LPTSTR lpVolumeNameBuffer, 'L', #DWORD nVolumeNameSize, 'P', #LPDWORD lpVolumeSerialNumber, 'P', #LPDWORD lpMaximumComponentLength, 'P', #LPDWORD lpFileSystemFlags, 'P', #LPTSTR lpFileSystemNameBuffer, 'L' #DWORD nFileSystemNameSize ] returnValue = 'I' # BOOL fileSysNameBuf = "\0" * MAX_PATH volumeName = "\0" * MAX_PATH serialNumber = ' ' * 4 dwSysFlags = ' ' * 4 fileNameLen = ' ' * 4 getVolumeInformation = Win32API.new("kernel32", "GetVolumeInformation", params, returnValue) if getVolumeInformation.call(buf, volumeName, MAX_PATH, serialNumber, fileNameLen, dwSysFlags, fileSysNameBuf, MAX_PATH) == 0 fileSysNameBuf = volumeName = nil else volumeName.gsub!(/\0/, '') volumeName.strip! fileSysNameBuf.gsub!(/\0/, '') fileSysNameBuf.strip! end return volumeName , fileSysNameBuf end p getVolInfo('C:\\') p getVolInfo('A:\\') # end code