// Sets the value of the current version of Pocket Pollster into the mobile device's registry.
        public static void SetAppVersion(string version)
        {
            CERegistryKey regKey = GetMobileAppKey();

            if (regKey != null)
            {
                regKey.SetValue("Version", version);
                regKey.Close();
            }
        }
        // Sets the value of "AppPath".
        public static void SetAppPath(string path)
        {
            CERegistryKey regKey = GetMobileAppKey();

            if (regKey != null)
            {
                regKey.SetValue("AppPath", path);
                regKey.Close();
            }
        }
        // Creates the "StopAskingToInstall" flag and sets it to the specified value.
        public static void SetStopAskingToInstall(bool newval)
        {
            CERegistryKey regKey = GetMobileAppKey();

            if (regKey != null)
            {
                regKey.SetValue("StopAskingToInstall", newval ? 1 : 0);
                regKey.Close();
            }
        }
        private void WriteRegistry(CERegistryKey rootKey, string name, object value, params string[] subKeys)
        {
            CERegistryKey key = rootKey;

            foreach (string subKey in subKeys)
            {
                key = key.CreateSubKey(subKey);
            }

            key.SetValue(name, value);
        }
        // Stores the Desktop's date & time onto the mobile computer.
        public static void SetNewTime()
        {
            CERegistryKey regKey = GetMobileAppKey();

            if (regKey != null)
            {
                //regKey.SetValue("NewTime", DateTime.Now.ToString());
                regKey.SetValue("NewTime", DateTime.Now.ToString("s"));
                regKey.Close();
            }
        }
        // If Pocket Pollster has been previously installed then this method changes the "Instl"
        // key from 1 to 0 so that the confirmation dialog doesn't appear on the mobile device.
        public static void ResetInstallFlag()
        {
            string flagPath = @"SOFTWARE\Apps\IMS Pocket Pollster";

            CERegistryKey regKey = CERegistry.LocalMachine.OpenSubKey(flagPath);

            // Only continue if the app was previously installed
            if (regKey != null)
            {
                regKey.SetValue("Instl", 0);
                regKey.Close();
            }
        }
        // Creates a new "Guid" value here and then sets it in the registry on the mobile device.
        public static string SetNewGuid()
        {
            string guid = System.Guid.NewGuid().ToString();

            CERegistryKey regKey = GetMobileAppKey();

            if (regKey != null)
            {
                regKey.SetValue("Guid", guid);
                regKey.Close();
            }

            return(guid);
        }
        // Sets a special key to inform WCELOAD where to install Pocket Pollster.
        public static void SetInstallLocation(string cabLocation, string destPath)
        {
            string installPath = @"SOFTWARE\Apps\Microsoft Application Installer\Install";

            CERegistryKey regKey = CERegistry.LocalMachine.OpenSubKey(installPath);

            if (regKey == null)
            {
                regKey = CERegistry.LocalMachine.CreateSubKey(installPath);
            }

            if (regKey != null)
            {
                regKey.SetValue(cabLocation, destPath);
                regKey.Close();
            }
        }