/// <summary> /// Examines a shortcut and returns its product, feature name, and component if available. /// </summary> /// <param name="shortcut">Full path to a shortcut</param> /// <returns>ShortcutTarget structure containing target product code, feature, and component code</returns> /// <remarks><p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msigetshortcuttarget.asp">MsiGetShortcutTarget</a> /// </p></remarks> public static ShortcutTarget GetShortcutTarget(string shortcut) { StringBuilder productBuf = new StringBuilder(40); StringBuilder featureBuf = new StringBuilder(40); StringBuilder componentBuf = new StringBuilder(40); uint ret = NativeMethods.MsiGetShortcutTarget(shortcut, productBuf, featureBuf, componentBuf); if (ret != 0) { throw InstallerException.ExceptionFromReturnCode(ret); } return(new ShortcutTarget( productBuf.Length > 0 ? productBuf.ToString() : null, featureBuf.Length > 0 ? featureBuf.ToString() : null, componentBuf.Length > 0 ? componentBuf.ToString() : null)); }