Creating windows shortcut files

G

Gabstar

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

Thomas Hawtin

Gabstar said:
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
 
R

Real Gagnon

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

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

Oliver Wong

Gabstar said:
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?

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
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top