context: #region License Information
  /* 
  
      SalesLogix Mobile Developer Tools
      Copyright (C) 2012  Customer FX Corporation - http://customerfx.com/
  
      This program is free software: you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
      the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.
  
      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.
  
      You should have received a copy of the GNU General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
  	
  	ADDITIONAL TERMS: 
  	The "Customer FX" link to customerfx.com on the main form must 
  	remain visible and in-tact on any forks or use of this source code.
  
      Contact Information:
      
      Ryan Farley 
      Customer FX Corporation
      http://customerfx.com/
      2324 University Avenue West, Suite 115
      Saint Paul, Minnesota 55114
      Tel: 651.646.7777  Fax: 651.846.5185
      
      This copyright must remain intact
      
  */
  #endregion
  
  using System;
  using System.Drawing;
  using System.Runtime.InteropServices;
  using System.Text;
  using System.Windows.Forms;
  
  namespace FX.Mobile.DeveloperTools.Utility
  {
  	#region ShellLink Object
  	/// <summary>
  	/// Summary description for ShellLink.
  	/// </summary>
  	public class ShellLink : IDisposable
  	{
  		#region ComInterop for IShellLink
  
  		#region IPersist Interface
  		[ComImportAttribute()]
  		[GuidAttribute("0000010C-0000-0000-C000-000000000046")]
  		[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
  		private interface IPersist
  		{
  			[PreserveSig]
  				//[helpstring("Returns the class identifier for the component object")]
  			void GetClassID(out Guid pClassID);
  		}
  		#endregion
  
  		#region IPersistFile Interface
  		[ComImportAttribute()]
  		[GuidAttribute("0000010B-0000-0000-C000-000000000046")]
  		[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
  		private interface IPersistFile
  		{
  			// can't get this to go if I extend IPersist, so put it here:
  			[PreserveSig]
  			void GetClassID(out Guid pClassID);
  
  			//[helpstring("Checks for changes since last file write")]		
  			void IsDirty();
  
  			//[helpstring("Opens the specified file and initializes the object from its contents")]		
  			void Load(
  				[MarshalAs(UnmanagedType.LPWStr)] string pszFileName, 
  				uint dwMode);
  
  			//[helpstring("Saves the object into the specified file")]		
  			void Save(
  				[MarshalAs(UnmanagedType.LPWStr)] string pszFileName, 
  				[MarshalAs(UnmanagedType.Bool)] bool fRemember);
  
  			//[helpstring("Notifies the object that save is completed")]		
  			void SaveCompleted(
  				[MarshalAs(UnmanagedType.LPWStr)] string pszFileName);
  
  			//[helpstring("Gets the current name of the file associated with the object")]		
  			void GetCurFile(
  				[MarshalAs(UnmanagedType.LPWStr)] out string ppszFileName);
  		}
  		#endregion
  
  		#region IShellLink Interface
  		[ComImportAttribute()]
  		[GuidAttribute("000214EE-0000-0000-C000-000000000046")]
  		[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
  		private interface IShellLinkA
  		{
  			//[helpstring("Retrieves the path and filename of a shell link object")]
  			void GetPath(
  				[Out(), MarshalAs(UnmanagedType.LPStr)] StringBuilder pszFile, 
  				int cchMaxPath, 
  				ref _WIN32_FIND_DATAA pfd, 
  				uint fFlags);
  
  			//[helpstring("Retrieves the list of shell link item identifiers")]
  			void GetIDList(out IntPtr ppidl);
  
  			//[helpstring("Sets the list of shell link item identifiers")]
  			void SetIDList(IntPtr pidl);
  
  			//[helpstring("Retrieves the shell link description string")]
  			void GetDescription(
  				[Out(), MarshalAs(UnmanagedType.LPStr)] StringBuilder pszFile,
  				int cchMaxName);
  		
  			//[helpstring("Sets the shell link description string")]
  			void SetDescription(
  				[MarshalAs(UnmanagedType.LPStr)] string pszName);
  
  			//[helpstring("Retrieves the name of the shell link working directory")]
  			void GetWorkingDirectory(
  				[Out(), MarshalAs(UnmanagedType.LPStr)] StringBuilder pszDir,
  				int cchMaxPath);
  
  			//[helpstring("Sets the name of the shell link working directory")]
  			void SetWorkingDirectory(
  				[MarshalAs(UnmanagedType.LPStr)] string pszDir);
  
  			//[helpstring("Retrieves the shell link command-line arguments")]
  			void GetArguments(
  				[Out(), MarshalAs(UnmanagedType.LPStr)] StringBuilder pszArgs, 
  				int cchMaxPath);
  
  			//[helpstring("Sets the shell link command-line arguments")]
  			void SetArguments(
  				[MarshalAs(UnmanagedType.LPStr)] string pszArgs);
  
  			//[propget, helpstring("Retrieves or sets the shell link hot key")]
  			void GetHotkey(out short pwHotkey);
  			//[propput, helpstring("Retrieves or sets the shell link hot key")]
  			void SetHotkey(short pwHotkey);
  
  			//[propget, helpstring("Retrieves or sets the shell link show command")]
  			void GetShowCmd(out uint piShowCmd);
  			//[propput, helpstring("Retrieves or sets the shell link show command")]
  			void SetShowCmd(uint piShowCmd);
  
  			//[helpstring("Retrieves the location (path and index) of the shell link icon")]
  			void GetIconLocation(
  				[Out(), MarshalAs(UnmanagedType.LPStr)] StringBuilder pszIconPath, 
  				int cchIconPath, 
  				out int piIcon);
  		
  			//[helpstring("Sets the location (path and index) of the shell link icon")]
  			void SetIconLocation(
  				[MarshalAs(UnmanagedType.LPStr)] string pszIconPath, 
  				int iIcon);
  
  			//[helpstring("Sets the shell link relative path")]
  			void SetRelativePath(
  				[MarshalAs(UnmanagedType.LPStr)] string pszPathRel, 
  				uint dwReserved);
  
  			//[helpstring("Resolves a shell link. The system searches for the shell link object and updates the shell link path and its list of identifiers (if necessary)")]
  			void Resolve(
  				IntPtr hWnd, 
  				uint fFlags);
  
  			//[helpstring("Sets the shell link path and filename")]
  			void SetPath(
  				[MarshalAs(UnmanagedType.LPStr)] string pszFile);
  		}
  
  
  		[ComImportAttribute()]
  		[GuidAttribute("000214F9-0000-0000-C000-000000000046")]
  		[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
  		private interface IShellLinkW
  		{
  			//[helpstring("Retrieves the path and filename of a shell link object")]
  			void GetPath(
  				[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, 
  				int cchMaxPath, 
  				ref _WIN32_FIND_DATAW pfd, 
  				uint fFlags);
  
  			//[helpstring("Retrieves the list of shell link item identifiers")]
  			void GetIDList(out IntPtr ppidl);
  
  			//[helpstring("Sets the list of shell link item identifiers")]
  			void SetIDList(IntPtr pidl);
  
  			//[helpstring("Retrieves the shell link description string")]
  			void GetDescription(
  
gt: 				[Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile,