Hi,
I was wondering if anyone had any experience of creating or editing
windows shortcut files (.lnk) from java. I've had a search on this
forum, but I can't find any recent posts on the subject.
I want to find a shortcut on a PC, then associate an icon with it and
save it.
I'm pretty confident that I can find the shortcut file, and I've got
documentation for the file format so I should be able to edit the file
correctly (although if anyone knows where I could find some sample
code, it would save me some work!). What I'm not sure about is if the
registry needs editing for it to work. Anyone out there have any ideas?
Thanks.
Thomas Hawtin - 29 May 2006 20:40 GMT
> I'm pretty confident that I can find the shortcut file, and I've got
> documentation for the file format so I should be able to edit the file
> correctly (although if anyone knows where I could find some sample
> code, it would save me some work!). What I'm not sure about is if the
> registry needs editing for it to work. Anyone out there have any ideas?
There is some information in Hack #30 "Real Windows Shortcut Support" in
Joshua Marinacci and Chris Adamson's Swing Hacks. But it seems to just
extract attributes and target file name.
http://www.amazon.co.uk/exec/obidos/ASIN/0596009070/
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
Gabstar - 29 May 2006 21:08 GMT
Thanks, I'll take a look, it should point me in the right direction at
least.
Real Gagnon - 29 May 2006 22:41 GMT
> I was wondering if anyone had any experience of creating or editing
> windows shortcut files (.lnk) from java. I've had a search on this
[quoted text clipped - 3 lines]
> save it.
> ...
See my HowTo "Display icon associated with an executable" at
http://www.rgagnon.com/javadetails/java-0439.html
File f2 = new File("c:/windows/regedit.exe");
jp2.add(new JLabel
(FileSystemView.getFileSystemView().getSystemIcon(f2)));
jp2.add(new JLabel(f2.getCanonicalPath()));
FileSystemView is in the javax.swing.filechooser package
Bye.

Signature
Real Gagnon from Quebec, Canada
* Looking for Java or PB code examples ? Visit Real's How-to
* http://www.rgagnon.com/howto.html
Oliver Wong - 30 May 2006 18:10 GMT
> Hi,
>
[quoted text clipped - 10 lines]
> code, it would save me some work!). What I'm not sure about is if the
> registry needs editing for it to work. Anyone out there have any ideas?
You shouldn't need to touch the registry for any of the above. The
filename of the file containing the icon is stored within the shortcut, not
within the registry. See
http://www.i2s-lab.com/Papers/The_Windows_Shortcut_File_Format.pdf
- Oliver