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. Advertising

  2. Don Hamilton

    Chris Smith Guest

    Don Hamilton <> wrote:
    > 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).

    --
    Chris Smith - Lead Software Developer / Technical Trainer
    MindIQ Corporation
    Chris Smith, Jun 5, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UHJhZGVlcCBTdW5kYXJhbShNU0ZUKQ==?=

    Enumerate all the drives including Mapped network drives on a serv

    =?Utf-8?B?UHJhZGVlcCBTdW5kYXJhbShNU0ZUKQ==?=, Feb 25, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,015
    =?Utf-8?B?UHJhZGVlcCBTdW5kYXJhbShNU0ZUKQ==?=
    Feb 26, 2005
  2. David Goulet

    Removable Drive

    David Goulet, Jan 20, 2004, in forum: Java
    Replies:
    2
    Views:
    378
    Christophe Vanfleteren
    Jan 20, 2004
  3. Heiko Selber

    Name/ID of removable Media: how?

    Heiko Selber, Apr 19, 2005, in forum: Python
    Replies:
    4
    Views:
    2,094
    Claudio Grondi
    Apr 19, 2005
  4. Tim Golden

    RE: Name/ID of removable Media: how?

    Tim Golden, Apr 19, 2005, in forum: Python
    Replies:
    1
    Views:
    344
    Heiko Selber
    Apr 19, 2005
  5. RunLevelZero
    Replies:
    4
    Views:
    459
    Mike Meyer
    Jun 5, 2005
Loading...

Share This Page