title: GetSystemMetrics() returns different results for .NET 4.5 & .NET 4.0
body: <p>During a .NET 4.0 -> .NET 4.5 application migration process I've discovered an extremely strange behavior. I've been able to track this issue down to this short code snippet:</p>
  
  <pre><code>class Program
  {
      [System.Runtime.InteropServices.DllImport("user32.dll")]
      public static extern int GetSystemMetrics(int nIndex);
  
      static void Main(string[] args)
      {
          const int CXFRAME = 0x20;
          const int CYFRAME = 0x21;
  
          var dx = GetSystemMetrics(CXFRAME);
          var dy = GetSystemMetrics(CYFRAME);
  
          Console.WriteLine("{0}x{1}", dx, dy);
          Console.ReadKey();
      }
  }
  </code></pre>
  
  <p>When compiled with <code>Target Framework = 4.0</code> (and also 2.0, 3.0, 3.5), it outputs <code>8x8</code></p>
  
  <p>When compiled with <code>Target Framework = 4.5</code>, it outputs <code>4x4</code></p>
  
  <p>Running this sample with MSVS2012 debugger also always outputs <code>4x4</code> (with <em>any</em> target framework).</p>
  
  <p>Other options (target framework profile, target platform, enabling/disabling Aero) do not affect the result, the only things that change the output are target framework and running with debugger. I've been able to reproduce this issue on 3 computers, unfortunately they are almost identical in terms of installed software:</p>
  
  <ul>
  <li>Windows 7 Ultmate SP1 (russian, all updates installed) with MSVS2012 (english/rusian) Update 1</li>
  <li>Windows 8 (on virtual machine)</li>
  </ul>
  
  <p>Currently I'm thinking about patching some .NET classes (<code>SystemParameters</code> for example), which call <code>GetSystemMetrics()</code> using reflection, but I'm not sure how to get correct metric values.</p>
  
  <p>Questions:</p>
  
  <ul>
  <li>Am I missing something? How can <code>GetSystemMetrics()</code> be affected by target framework?</li>
  <li>Is there any way to call <code>GetSystemMetrics()</code> from .NET 4.5 app and get correct results?</li>
  </ul>
  
  <p>I'm open to any suggestions on fixing this issue. Also, if you cannot reproduce the issue, please leave a short system description in comments.</p>