Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

Creating windows shortcut files

Thread view: 
Gabstar - 29 May 2006 20:22 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.