Wednesday, December 26, 2012

how to set product key to windows application

write into registry         
           
            int z = 14;                   
     string productkey="giveyourproductkey";
            try
            {
                if (txtproductkey.Text == productkey)
                {
                    RegistryKey softwareKey =
                    Registry.LocalMachine.OpenSubKey("Software", true);
                    RegistryKey wroxKey = softwareKey.CreateSubKey("HOTEL");
                    RegistryKey selfPlacingWindowKey =
                                wroxKey.CreateSubKey("SelfPlacingWindow");
                    selfPlacingWindowKey.SetValue("HT", (int)z);
                    selfPlacingWindowKey.SetValue("WindowState",
                        (object)WindowState.ToString());
                    MessageBox.Show("Registered Successfully,Login Now", "Hotel Taj", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
         }


read from registry


        int redComponent;

            RegistryKey softwareKey =
               Registry.LocalMachine.OpenSubKey("Software");
            RegistryKey wroxKey = softwareKey.OpenSubKey("HOTEL");
            if (wroxKey == null)
            {
                Productkey pr = new Productkey();
                pr.Show();
                return;
            }    
               
            RegistryKey selfPlacingWindowKey =
                        wroxKey.OpenSubKey("SelfPlacingWindow");
            if (selfPlacingWindowKey == null)
                return;

(The above coding helps to check  product key before to use windows application software)


No comments:

Post a Comment