Detect Removable Drives

Discussion in 'Java' started by Don Hamilton, Jun 5, 2006.

  1. Don Hamilton

    Don Hamilton Guest

    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.
     
    Don Hamilton, Jun 5, 2006
    #1
    1. Advertisements

  2. Don Hamilton

    Chris Smith Guest

    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).
     
    Chris Smith, Jun 5, 2006
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.