Re: [WIN] GetLogicalDrives returns drives NOT present

new topic     » goto parent     » topic index » view thread      » older message » newer message

Chris,

Here's what works for me, get the include from user contrib, I just removed some
unused vars from in for my use:
include win32lib.ew
include getvolumeinfo.ew  -- FROM USER CONTRIBS



constant xGetLogicalDrives = registerw32Function(kernel32,"GetLogicalDrives",
{},C_LONG  )
,xGetDriveType = registerw32Function(kernel32,"GetDriveTypeA",
        {C_POINTER},C_LONG  )
          
integer aResult, theResult
integer dummy
sequence volumeResult, drivesPresent

procedure CheckForRemovable(sequence aDrive)
   puts(1, aDrive & "://") 
   if w32Func(xGetDriveType, {aDrive & "://"}) = 2 then
      puts(1, " REMOVABLE DRIVE")
      volumeResult = getVolumeInformation (aDrive & "://")

      if equal(volumeResult[5], {}) then
         puts(1, " drive not ready")
      else
         puts(1, " READY")
      end if 
   else
      puts(1, "non removable drive")
   end if

end procedure

aResult= w32Func(xGetLogicalDrives, {})
puts(1, sprint(aResult)& "\n")
theResult = aResult
puts(1, " bits: " & sprint(int_to_bits(aResult, 26)) & " ** \n")
drivesPresent = int_to_bits(aResult, 26) 
puts(1, "drives present: " & drivesPresent)

puts(1, "\n\n")


puts(1, "drives present: " & sprint(drivesPresent) & "\n")
for n = 1 to length(drivesPresent) do
  if equal(drivesPresent[n], 1) then
     CheckForRemovable({n + 64} )
  end if
  puts(1, "\n")
end for


dummy = wait_key()


new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu