GetDrives() , wrapped

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

Here's a wrapped GetLogicalDrives function.
You can link it other ways if you like within your
own program.

Have fun,
--Al


--------------------------

include dll.e
include msgbox.e

global atom hKernel32_dll,hGetLogicalDrives
atom retv

hKernel32_dll=open_dll("kernel32.dll")

if hKernel32_dll=0 then
    retv=message_box( "could not locate 
Kernel32.dll","GetDrives.exw",MB_ICONHAND+MB_TASKMODAL )
    abort(1)
end if



hGetLogicalDrives=
    define_c_func(hKernel32_dll, "GetLogicalDrives", {}, C_ULONG)
if hGetLogicalDrives<0 then
    retv=message_box( "could not link to c 
function"�D�A&"GetLogicalDrives in 
Kernel32.dll","GetDrives.exw",MB_ICONHAND+MB_TASKMODAL)
    abort(1)
end if


retv=c_func(hGetLogicalDrives,{})


sequence message,windows_crlf,drive,Drives
windows_crlf=#0D�A
Drives={}

atom bit
integer DriveLetter

message="Drives available:"&windows_crlf

bit=1

for k=1 to 26 do
    if and_bits(bit,retv) then
      DriveLetter=k+96--change to "DriveLetter=k+64" for caps
      drive=DriveLetter&":\\"
      Drives=append(Drives,drive)
      message=message&drive&windows_crlf
    end if
    bit=bit*2
end for

?Drives --sequence of all drives available on the system
puts(1,"\n")

--display all drives to console:
for k=1 to length(Drives) do
    printf(1,"%s\n",{Drives[k]})
end for

--display all drives in message box:
retv=message_box( message,"GetDrives.exw",MB_TASKMODAL )

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

Search



Quick Links

User menu

Not signed in.

Misc Menu