// Retrieves the version number of the dotNet Compact Framework installed on the mobile device.
        public static string GetCFVersion(string keyPath)
        {
            string        version = null;
            CERegistryKey regKey  = CERegistry.LocalMachine.OpenSubKey(keyPath);

            if (regKey != null)
            {
                version = "1.0.2268.0"; // Some older versions of CF don't have any values so we can assume this version number
                string[] valNames = regKey.GetValueNames();
                if (valNames.Length != 0)
                {
                    version = valNames[0].TrimEnd(new char[] { '\0' }); // Store first possible version number

                    for (int i = 1; i < valNames.Length; i++)
                    {
                        string txt = valNames[i];
                        txt = txt.TrimEnd(new char[] { '\0' });
                        if (Tools.CompareVersionNumbers(txt, version) == 1)
                        {
                            version = txt;
                        }
                    }
                }
                regKey.Close();
            }

            return(Tools.DisallowNullString(version));
        }
        // Retrieves the version number of the OpenNET Framework installed on the mobile device.
        public static string GetOpenNETCFVersion(string keyPath, string valPrefix)
        {
            string version = null;

            valPrefix = valPrefix.ToLower();
            CERegistryKey regKey = CERegistry.LocalMachine.OpenSubKey(keyPath);

            if (regKey != null)
            {
                string[] valNames = regKey.GetValueNames();

                for (int i = 0; i < valNames.Length; i++)
                {
                    string txt = valNames[i].ToLower();
                    txt = txt.TrimEnd(new char[] { '\0' });
                    if (txt.StartsWith(valPrefix))
                    {
                        int pos = txt.IndexOf("version=");
                        if (pos != -1)
                        {
                            txt = txt.Substring(pos + 8);
                            pos = txt.IndexOf(",");
                            if (pos == -1)
                            {
                                version = txt; // Must be at the end of the string
                            }
                            else
                            {
                                version = txt.Substring(0, pos);
                            }
                        }
                        break;
                    }
                }
                regKey.Close();
            }

            return(Tools.DisallowNullString(version));
        }