Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to get the path of a selected file in explorer.exe. I need it from something System Variable or somewhere as I can read in with a java application.

share|improve this question

1 Answer 1

There isn't a system level attribute that will allow you to observe the selected file. there are a couple options, but both are pretty big detours.

the most traditional approach is to have your java app spawn the window in question, via some API that allows you to retrieve the file information on some event. the jFileChooser is one of these.

another approach is to leverage the windows API directly. you would need to capture the window handle of the windows explorer instance and inspect it with an object like ShellWindows. see some more info here: http://blogs.msdn.com/b/oldnewthing/archive/2004/07/20/188696.aspx

http://stackoverflow.com/questions/2518257/get-the-selected-file-in-an-explorer-window

not sure how to interface with the winAPI via java, but I;m sure there's a way.

This probably belongs on StackOverflow instead of SU.

share|improve this answer
    
the first link you gave me, is not a java code, how can i translate it? –  night_angel90 Feb 20 '13 at 13:49
    
windows API code is never going to be in java, but there should be an interface you can use to access it via the JDK. here is some general info about importing a windows api dll, and invoking its members: rgagnon.com/javadetails/java-0189.html –  Frank Thomas Feb 20 '13 at 14:22
    
@night_angel90: I think what you're looking for based on Frank's suggestion is JNI. –  Karan Feb 21 '13 at 4:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.