Gary,
Ignacio and Dave already replied with helpful tips, but regarding your
question #2, I want to give more information and some C# code.
Firstly, shortcuts or "shell links" as they are also called can be
manipulated using the COM objects in SHELL32.DLL, and there exists the
IShellLink interface and the ShellLinkObject object, the latter of which is
very useful. If you are using Visual Studio, you can simply add a reference
to the COM library "Microsoft Shell Control And Automation" or to
SHELL32.DLL directly, and then use the following code:
----------------------------
public string GetShortcutTarg etFile(string shortcutFilenam e)
{
string pathOnly = System.IO.Path. GetDirectoryNam e(shortcutFilen ame);
string filenameOnly = System.IO.Path. GetFileName(sho rtcutFilename);
Shell32.Shell shell = new Shell32.ShellCl ass();
Shell32.Folder folder = shell.NameSpace (pathOnly);
Shell32.FolderI tem folderItem = folder.ParseNam e(filenameOnly) ;
if (folderItem != null)
{
Shell32.ShellLi nkObject link =
(Shell32.ShellL inkObject)folde rItem.GetLink;
return link.Path;
}
return ""; // not found
}
----------------------------
Then, you could use the above code simply like this:
----------------------------
private void button1_Click(o bject sender, EventArgs e)
{
string shortcut = "C:\\Shortc ut to notepad.exe.lnk ";
MessageBox.Show (GetShortcutTar getFile(shortcu t));
}
----------------------------
Finally, if you are interested in the file format, you can go to
http://www.wotsit.org/ and then search for "LNK". You will find three useful
documents. Finally, ShellLinkObject is documented here:
http://msdn2.microsoft.com/en-gb/library/ms630347.aspx
Hope this helps!
--
Regards,
Mr. Jani Järvinen
C# MVP
Helsinki, Finland
ja***@removethi s.dystopia.fi http://www.saunalahti.fi/janij/