resolving Windows shortcuts

To resolve UNIX links to files you can use File::getCanonicalPath(). Is there a similar function for resolving Windows shortcuts? getCanonicalPath() and getAbsolutePath() always just return myFile.lnk instead of the path to myFile.

I am not executing any of these files just trying to read them into my system for testing purposes.

[345 byte] By [ZodiacKhana] at [2007-11-27 9:35:24]
# 1
If there is no way to easily resolve the shortcut, is there a way if I recognize it as a shortcut, to get the file path out of it?
ZodiacKhana at 2007-7-12 23:02:24 > top of Java-index,Java Essentials,Java Programming...
# 2
AFAIK, Windows shortcuts are just text files, similar in structure to .ini files. I don't have a Windows machine to hand to check that (I'm guessing you do, though), but if it's the case, you could just parse the shortcut for the actual path
georgemca at 2007-7-12 23:02:24 > top of Java-index,Java Essentials,Java Programming...
# 3
If I just read in the bytes from the link I get a bunch of garbage. I tried using CharsetDecoder but none of the formats seems to ever return a valid string. It also hasn't seemed to work trying to change the .lnk to a URL and attempt to chase it that way.
ZodiacKhana at 2007-7-12 23:02:24 > top of Java-index,Java Essentials,Java Programming...
# 4
See http://www.wotsit.org/list.asp?al=LCheck on LNKYou may need to write C++ code....then use JNI to call from Java
polimetlaa at 2007-7-12 23:02:24 > top of Java-index,Java Essentials,Java Programming...
# 5
Unfortunately, the restrictions on the program I am in do not allow for C++. I'd need to recreate the same stuff in Java. However, it surprises me that there isn't an easy way to do this.
ZodiacKhana at 2007-7-12 23:02:24 > top of Java-index,Java Essentials,Java Programming...
# 6
I'm not understanding what you want to happen. You have a .lnk file that you want to follow to the file that it points to? Have I got that straight?PS.
puckstopper31a at 2007-7-12 23:02:24 > top of Java-index,Java Essentials,Java Programming...
# 7

> Unfortunately, the restrictions on the program I am

> in do not allow for C++. I'd need to recreate the

> same stuff in Java. However, it surprises me that

> there isn't an easy way to do this.

Java should be platform independent so I'm not surprised that you can't do it in an easy way.

kajbja at 2007-7-12 23:02:24 > top of Java-index,Java Essentials,Java Programming...
# 8
Found it.File linkedTo = new File(ShellFolder.getShellFolde(selectedFile).getLinkLocation().getAbsolutePath());
ZodiacKhana at 2007-7-12 23:02:24 > top of Java-index,Java Essentials,Java Programming...