Detect Removable Drives

D

Don Hamilton

Hi,

For a small Windows desktop application I needed a simple way to check
for the existence and drive names of cdrom drives. My immediate
inclination was to iterate through an array returned by list.Roots()
using File.exists() with empty drives as the test. But I seem to recall
that problems have been reported where exists() would'nt,in the case of
Win XP or one of its SP's, work as I expected

An alternative would be to use a WIM/script function, but again as I
understand it, accomodating the various flavours of Windows is not
entirely without problems.

As a relative novice I'm fumbling my way through this, so any comments
would be welcome as to the most reliable route to persue. I'm not
looking for example code, just a prod in the right direction.

As an aside, from what I read the emergence of Java 7 (Dolphin) might
possibly (MS permitting) put an end to this type of problem.

Don Hamilton.
 
C

Chris Smith

Don Hamilton said:
For a small Windows desktop application I needed a simple way to check
for the existence and drive names of cdrom drives. My immediate
inclination was to iterate through an array returned by list.Roots()
using File.exists() with empty drives as the test. But I seem to recall
that problems have been reported where exists() would'nt,in the case of
Win XP or one of its SP's, work as I expected

Indeed. The only reliable way to do what you want is to use Windows-
specific APIs, which means writing code in some other language than
Java. The interface between your non-Java code and the Windows
application would probably be JNI, although you could use something
else, such as standard I/O streams or a TCP socket, if you want to avoid
incorporating a C or C++ build environment into your project (assuming
you don't use C or C++ to write the API in the first place).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top