How check if program is running in compatible mode and display mode in title bar
<p>My program need to be run in XP compatible mode. I need  A way to check if is running in XP compatible mode. If not tell the user to run it in compatible mode. I have searched but found no answer. I have tried this <code>this.Text = System.Environment.OSVersion.VersionString;</code> but it returns Microsoft Windows NT 6.1.7601 Service Pack 1 not the emulated XP.</p>

<p>(Edit)</p>

<p>After more searches and dll imports nothing worked right it would always returns Microsoft Windows NT 6.1.7601 Service Pack 1. So I created A console loaded to handle registry then run my program.</p>

<pre><code>using System;
using System.Security.Permissions;
using Microsoft.Win32;

[assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum, ViewAndModify = "HKEY_CURRENT_USER")]

class RegKey
{
    static void Main()
    {
        int Major = Environment.OSVersion.Version.Major;
        int Minor = Environment.OSVersion.Version.Minor;

        if (Major == 5 &amp;&amp; Minor == 1)
        {   
            System.Diagnostics.Process.Start(System.IO.Directory.GetCurrentDirectory() + "\\MyApp.exe");
        }
        else if (Major &gt; 5)
        {
            if (System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory() + "\\MyApp.exe"))
            {
                RegistryKey Rkey = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers");
                //Creates Name And Value
                Rkey.SetValue(System.IO.Directory.GetCurrentDirectory() + "\\MyApp.exe", "WINXPSP3");
                //Starts App.
                 System.Diagnostics.Process.Start(System.IO.Directory.GetCurrentDirectory() + "\\MyApp.exe", "Load");

                //Waites 500 milliseconds so my program can get the registry info
                //(Not needed any more) 
                //System.Threading.Thread.Sleep(500);

                //Deletes Name And Value
                //(Handled by MyApp.exe to increase load time)
                //Rkey.DeleteValue(System.IO.Directory.GetCurrentDirectory() + "\\MyApp.exe");
            }
            else
            {
                Console.WriteLine("File Not Found!!!");
                Console.WriteLine("( MyApp.exe ) Must Be In Same Directory As The Loader.exe.");
                Console.ReadLine();
            }
        }
    }
}
</code></pre>

<p>I handle registry in this way so my program can be portable and prevent registry entries that point to nothing. I am shore that they are better ways to get the results I was looking for. </p>

<p>(Edit 2)</p>

<p>After more checking I only have to run XP compatible mode on 64 bit systems. 32 bit systems do not need to run in XP compatible mode. I compiled my app with platform x86. So it must has something to do with the way 64 bit systems read the registry.  </p>
