get drive type

Discussion in 'Java' started by Stefan Poehn, Jul 15, 2004.

  1. Stefan Poehn

    Stefan Poehn Guest

    Hi

    is there any possibility to find out the drive type of a given path ("C:",
    "D:", etc.)? I want to search through a complete hard disk drive to find a
    file with a given name, but not search through a cd rom drive, etc.

    Thanks
    Stefan
    Stefan Poehn, Jul 15, 2004
    #1
    1. Advertising

  2. Stefan Poehn wrote:
    > is there any possibility to find out the drive type of a given path ("C:",
    > "D:", etc.)? I want to search through a complete hard disk drive to find a
    > file with a given name, but not search through a cd rom drive, etc.


    Not in a platform-independant way. On Linux, you'd have to parse /etc/fstab;
    on Windows you'll probably have to use system calls via JNI.
    Michael Borgwardt, Jul 15, 2004
    #2
    1. Advertising

  3. Stefan Poehn

    Liz Guest

    "Michael Borgwardt" <> wrote in message
    news:...
    > Stefan Poehn wrote:
    > > is there any possibility to find out the drive type of a given path

    ("C:",
    > > "D:", etc.)? I want to search through a complete hard disk drive to find

    a
    > > file with a given name, but not search through a cd rom drive, etc.

    >
    > Not in a platform-independant way. On Linux, you'd have to parse

    /etc/fstab;
    > on Windows you'll probably have to use system calls via JNI.


    There must be a way cuz I've run programs on pc that show this info. You
    might
    have to call some system functions.
    Liz, Jul 16, 2004
    #3
  4. Stefan Poehn

    Stefan Poehn Guest

    See below..
    "Liz" <> schrieb im Newsbeitrag
    news:E7GJc.88002$%_6.19416@attbi_s01...
    >
    > "Michael Borgwardt" <> wrote in message
    > news:...
    > > Stefan Poehn wrote:
    > > > is there any possibility to find out the drive type of a given path

    > ("C:",
    > > > "D:", etc.)? I want to search through a complete hard disk drive to

    find
    > a
    > > > file with a given name, but not search through a cd rom drive, etc.

    > >
    > > Not in a platform-independant way. On Linux, you'd have to parse

    > /etc/fstab;
    > > on Windows you'll probably have to use system calls via JNI.

    >
    > There must be a way cuz I've run programs on pc that show this info. You
    > might
    > have to call some system functions.
    >


    Do these programs start without using a .dll or .so-File? If it is a Unix
    program, does it run without using /etc/fstab?
    Stefan Poehn, Jul 16, 2004
    #4
  5. Stefan Poehn

    Liz Guest

    "Stefan Poehn" <> wrote in message
    news:cd7u9q$19iv$...
    > See below..
    > "Liz" <> schrieb im Newsbeitrag
    > news:E7GJc.88002$%_6.19416@attbi_s01...
    > >
    > > "Michael Borgwardt" <> wrote in message
    > > news:...
    > > > Stefan Poehn wrote:
    > > > > is there any possibility to find out the drive type of a given path

    > > ("C:",
    > > > > "D:", etc.)? I want to search through a complete hard disk drive to

    > find
    > > a
    > > > > file with a given name, but not search through a cd rom drive, etc.
    > > >
    > > > Not in a platform-independant way. On Linux, you'd have to parse

    > > /etc/fstab;
    > > > on Windows you'll probably have to use system calls via JNI.

    > >
    > > There must be a way cuz I've run programs on pc that show this info. You
    > > might
    > > have to call some system functions.
    > >

    >
    > Do these programs start without using a .dll or .so-File? If it is a Unix
    > program, does it run without using /etc/fstab?
    >

    Ok, I looked at one of the programs, but all I have is the .exe file.
    I searched for ascii strings in the .exe and found "KERNEL32.dll"
    Then I used "dependency walker" to look at Kernel32.dll and I find two
    functions
    GetDriveTypeA and
    GetDriveTypeW which I assume you can use to get the info you need.
    Look at MSDN on the web (somewhere at microsoft.com) for details.
    Then you can write a little c/c++ program that calls GetDriveType[A|W].
    Then you can use the example at sun.com to call your program from java.
    HTH
    Liz, Jul 17, 2004
    #5
  6. Stefan Poehn

    Stefan Poehn Guest

    "Liz" <> schrieb im Newsbeitrag
    news:md0Kc.108634$XM6.88890@attbi_s53...
    >
    > "Stefan Poehn" <> wrote in message
    > news:cd7u9q$19iv$...
    > > See below..
    > > "Liz" <> schrieb im Newsbeitrag
    > > news:E7GJc.88002$%_6.19416@attbi_s01...
    > > >
    > > > "Michael Borgwardt" <> wrote in message
    > > > news:...
    > > > > Stefan Poehn wrote:
    > > > > > is there any possibility to find out the drive type of a given

    path
    > > > ("C:",
    > > > > > "D:", etc.)? I want to search through a complete hard disk drive

    to
    > > find
    > > > a
    > > > > > file with a given name, but not search through a cd rom drive,

    etc.
    > > > >
    > > > > Not in a platform-independant way. On Linux, you'd have to parse
    > > > /etc/fstab;
    > > > > on Windows you'll probably have to use system calls via JNI.
    > > >
    > > > There must be a way cuz I've run programs on pc that show this info.

    You
    > > > might
    > > > have to call some system functions.
    > > >

    > >
    > > Do these programs start without using a .dll or .so-File? If it is a

    Unix
    > > program, does it run without using /etc/fstab?
    > >

    > Ok, I looked at one of the programs, but all I have is the .exe file.
    > I searched for ascii strings in the .exe and found "KERNEL32.dll"
    > Then I used "dependency walker" to look at Kernel32.dll and I find two
    > functions
    > GetDriveTypeA and
    > GetDriveTypeW which I assume you can use to get the info you need.
    > Look at MSDN on the web (somewhere at microsoft.com) for details.
    > Then you can write a little c/c++ program that calls GetDriveType[A|W].
    > Then you can use the example at sun.com to call your program from java.


    Hmm, this can only be JNI... I didnt want to use it, but unfortunately it
    seems to be the only way to get the drive type (on windows).

    > HTH
    >
    >
    Stefan Poehn, Jul 19, 2004
    #6
  7. Stefan Poehn

    Liz Guest


    > > >
    > > > Do these programs start without using a .dll or .so-File? If it is a

    > Unix
    > > > program, does it run without using /etc/fstab?
    > > >

    > > Ok, I looked at one of the programs, but all I have is the .exe file.
    > > I searched for ascii strings in the .exe and found "KERNEL32.dll"
    > > Then I used "dependency walker" to look at Kernel32.dll and I find two
    > > functions
    > > GetDriveTypeA and
    > > GetDriveTypeW which I assume you can use to get the info you need.
    > > Look at MSDN on the web (somewhere at microsoft.com) for details.
    > > Then you can write a little c/c++ program that calls GetDriveType[A|W].
    > > Then you can use the example at sun.com to call your program from java.

    >
    > Hmm, this can only be JNI... I didnt want to use it, but unfortunately it
    > seems to be the only way to get the drive type (on windows).


    Remember, I did not use these functions myself so there is no guarantee that
    they will do what you want. Yoda says:
    "Look up what they do at MSDN first you should."
    Liz, Jul 19, 2004
    #7
    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. Jon
    Replies:
    5
    Views:
    11,127
    Scott M.
    Jan 17, 2010
  2. mh
    Replies:
    4
    Views:
    687
    Wolfgang Strobl
    May 31, 2005
  3. Tom Anderson
    Replies:
    8
    Views:
    384
    Gerrit Holl
    Sep 15, 2005
  4. Mike Joyce
    Replies:
    3
    Views:
    3,121
    Gordon Rainsford
    May 3, 2006
  5. shailesh
    Replies:
    1
    Views:
    764
    Tim Golden
    Mar 28, 2007
Loading...

Share This Page