get drive type

S

Stefan Poehn

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
 
M

Michael Borgwardt

Stefan said:
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.
 
L

Liz

Michael Borgwardt said:
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.
 
S

Stefan Poehn

See below..
Liz said:
find

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?
 
L

Liz

Stefan Poehn said:
See below..


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
 
S

Stefan Poehn

Liz said:
Stefan Poehn said:
See below..
to
find

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).
 
L

Liz

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

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,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top