コード例 #1
0
        /// <summary>
        /// Event handler that is fired when this form is shown.
        /// Changes window title and gets current Windows Product Key.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_Shown(object sender, EventArgs e)
        {
            // get the assembly information to display current version in the title of the window
            var assemblyName = AssemblyName.GetAssemblyName(Assembly.GetExecutingAssembly().Location);

            // format window title text (append version to the current title)
            Text = $@"{Text} v{assemblyName.Version.Major}.{assemblyName.Version.Minor}";

            // get the current Windows Product Key and display it
            tbWindowsProductKey.Text = KeyDecoder.GetWindowsProductKeyFromRegistry();
        }