title: c# dllimport of MsiGetShortcutTarget(msi.dll) failed with error 1603 under Windows 7
body: <p>I want to resolve an advertised MSI shortcut in c# as described here:
  <a href="http://www.geektieguy.com/2007/11/19/how-to-parse-special-lnk-files-aka-msi-shortcuts-aka-windows-installer-advertised-shortcuts-using-c/" rel="nofollow">How to parse "special" .lnk files, aka. MSI shortcuts aka. Windows Installer advertised shortcuts using C#</a></p>
  
  <pre><code>[DllImport("msi.dll", CharSet = CharSet.Auto)]
  private static extern UInt32 MsiGetShortcutTarget(
      string szShortcutTarget,
      [Out] StringBuilder szProductCode,
      [Out] StringBuilder szFeatureId,
      [Out] StringBuilder szComponentCode);
  
  public static string ParseShortcut(string file)
  {
      StringBuilder product = new StringBuilder(MaxGuidLength + 1);
      StringBuilder feature = new StringBuilder(MaxFeatureLength + 1);
      StringBuilder component = new StringBuilder(MaxGuidLength + 1);
  
      UInt32 res = MsiGetShortcutTarget(file, product, feature, component);
      ...
  }
  </code></pre>
  
  <p>I use VS 2010 and tried with different settings for "Platform target" and/or "Target framework". MsiGetShortcutTarget always returns 1603 (A fatal error occurred during installation) under Windows 7.</p>
  
  <p>I tried to do the same with c++ and I can resolve the Shortcut and everything is fine. I also tested with a msi.dll, that I copied from a Windows XP and this dll can resolve the Shortcut with the C# code. I have no idea why the c# code won't work with the msi.dll under Windows 7.</p>
  
  <p>I testet MsiGetComponentPath with a known product GUID and component GUID to resolve the target path in c# with the dll, that returns 1603 for MsiGetShortcutTarget and it works perfectly. So only MsiGetComponentPath fails under Windows 7 and I don't know why it went wrong.</p>