HOW TO START THE APPLICATION AT STARTUP -WINDOWS FORM

To start up application at startup you need to use that library:
Code:

Using System.Microsoft.Win32;

Then insert the value into Registry :
Code:

RegistryKey doit = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
doit.SetValue("ApplicationName", "ApplicationPath");
doit.Close();


How to Turn OFF the Display using C# -WINDOWS FORM

Turning OFF the Display using C#

first of all , you need to use that library :
Code:
using System.Runtime.InteropServices; // for dll import

Then add these under public class :
Code:
//Using the system pre-defined MSDN constants that can b used by the SendMessage()
       
        public int WM_SYSCOMMAND = 0x0112;
        public int SC_MONITORPOWER = 0xF170;

        //To call a DLL function from C#, you must provide this declaration .
        [DllImport("user32.dll")]
    private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);

Finally when button clicked , add this function :
Code:
            // this will turn off display
            SendMessage(this.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, 2);


Key or Password Generator -WINDOWS FORM

STEP -1 :
TAKE A EMPTY FORM & NAME IT AS FORM1  
Now, Paste The Code Below To FORM1.DESIGNER.CS :


------------------------------------------------------------------------------------
namespace Password_Generator
{
    partial class Form1
    {
      
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.checkBox1 = new System.Windows.Forms.CheckBox();
            this.checkBox2 = new System.Windows.Forms.CheckBox();
            this.checkBox3 = new System.Windows.Forms.CheckBox();
            this.label5 = new System.Windows.Forms.Label();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.button1 = new System.Windows.Forms.Button();
            this.comboBox1 = new System.Windows.Forms.ComboBox();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(271, 28);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(125, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "Generate Your Password";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(147, 66);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(92, 13);
            this.label2.TabIndex = 1;
            this.label2.Text = "Include Alphabets";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(147, 108);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(89, 13);
            this.label3.TabIndex = 2;
            this.label3.Text = "Include Numerics";
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Location = new System.Drawing.Point(147, 150);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(134, 13);
            this.label4.TabIndex = 3;
            this.label4.Text = "Include Special Characters";
            // 
            // checkBox1
            // 
            this.checkBox1.AutoSize = true;
            this.checkBox1.Location = new System.Drawing.Point(350, 62);
            this.checkBox1.Name = "checkBox1";
            this.checkBox1.Size = new System.Drawing.Size(80, 17);
            this.checkBox1.TabIndex = 4;
            this.checkBox1.Text = "checkBox1";
            this.checkBox1.UseVisualStyleBackColor = true;
            this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
            // 
            // checkBox2
            // 
            this.checkBox2.AutoSize = true;
            this.checkBox2.Location = new System.Drawing.Point(350, 103);
            this.checkBox2.Name = "checkBox2";
            this.checkBox2.Size = new System.Drawing.Size(80, 17);
            this.checkBox2.TabIndex = 5;
            this.checkBox2.Text = "checkBox2";
            this.checkBox2.UseVisualStyleBackColor = true;
            this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
            // 
            // checkBox3
            // 
            this.checkBox3.AutoSize = true;
            this.checkBox3.Location = new System.Drawing.Point(350, 144);
            this.checkBox3.Name = "checkBox3";
            this.checkBox3.Size = new System.Drawing.Size(80, 17);
            this.checkBox3.TabIndex = 6;
            this.checkBox3.Text = "checkBox3";
            this.checkBox3.UseVisualStyleBackColor = true;
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Location = new System.Drawing.Point(147, 192);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(89, 13);
            this.label5.TabIndex = 8;
            this.label5.Text = "Password Length";
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(255, 243);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(310, 20);
            this.textBox1.TabIndex = 9;
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(150, 240);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 10;
            this.button1.Text = "Generate";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // comboBox1
            // 
            this.comboBox1.FormattingEnabled = true;
            this.comboBox1.Location = new System.Drawing.Point(350, 184);
            this.comboBox1.Name = "comboBox1";
            this.comboBox1.Size = new System.Drawing.Size(121, 21);
            this.comboBox1.TabIndex = 11;
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(577, 318);
            this.Controls.Add(this.comboBox1);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.checkBox3);
            this.Controls.Add(this.checkBox2);
            this.Controls.Add(this.checkBox1);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.CheckBox checkBox1;
        private System.Windows.Forms.CheckBox checkBox2;
        private System.Windows.Forms.CheckBox checkBox3;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.ComboBox comboBox1;
    }

}

-----------------------------------------------------------------------------------------
STEP-2 :
NOW GO TO THE CODE FILE AND
  Paste the below given code to your FORM1.CS page,


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Password_Generator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBox1.SelectedItem.ToString() != "" || int.Parse(comboBox1.SelectedItem.ToString()) != 0)
                {
                    if (!checkBox1.Checked && !checkBox2.Checked && !checkBox3.Checked)
                    {
                        MessageBox.Show("Please at least one checkbox", "Error", MessageBoxButtons.OK);
                    }

                    else if (checkBox1.Checked == true || checkBox2.Checked == true)
                    {
                        if (checkBox1.Checked && checkBox2.Checked && checkBox3.Checked)
                        {
                            inc_alpha_num_spch();
                        }
                        else if (checkBox1.Checked && checkBox2.Checked && !checkBox3.Checked)
                        {
                            inc_alpha_num();
                        }
                        else if (checkBox1.Checked && !checkBox2.Checked && checkBox3.Checked)
                        {
                            inc_alpha_spch();
                        }
                        else if (!checkBox1.Checked && checkBox2.Checked && checkBox3.Checked)
                        {
                            inc_num_spch();
                        }
                        else if (checkBox1.Checked)
                        {
                            inc_alpha_only();
                        }
                        else if(checkBox2.Checked)
                        {
                            inc_num_only();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please Select length of your password");
                }
            }
            catch (Exception Error)
            {
                MessageBox.Show(Error.ToString(), "Exception Found", MessageBoxButtons.OK);
            }
        }

        public void inc_num_only()
        {
            try
            {
                int p_len, x;
                string code = "";
                char[] letter = "1234567890".ToCharArray();
                p_len = int.Parse(comboBox1.SelectedItem.ToString());
                Random random = new Random();
                for (x = 0; x < p_len; x++)
                {
                    code += letter[random.Next(1, letter.Length)].ToString();
                }
                textBox1.Text = code.ToString();
            }
            catch (Exception Error)
            {
                MessageBox.Show(Error.ToString(), "Exception Found", MessageBoxButtons.OK);
            }
        }

        public void inc_alpha_only()
        {
            try
            {
                int p_len, x;
                string code = "";
                char[] letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();
                p_len = int.Parse(comboBox1.SelectedItem.ToString());
                Random random = new Random();
                for (x = 0; x < p_len; x++)
                {
                    code += letter[random.Next(1, letter.Length)].ToString();
                }
                textBox1.Text = code.ToString();
            }
            catch (Exception Error)
            {
                MessageBox.Show(Error.ToString(), "Exception Found", MessageBoxButtons.OK);
            }
        }

        public void inc_alpha_num_spch()
        {
            try
            {
                int p_len, x;
                string code = "";
                char[] letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()".ToCharArray();
                p_len = int.Parse(comboBox1.SelectedItem.ToString());
                Random random = new Random();
                for (x = 0; x < p_len; x++)
                {
                    code += letter[random.Next(1, letter.Length)].ToString();
                }
                textBox1.Text = code.ToString();
            }
            catch(Exception Error)
            {
                MessageBox.Show(Error.ToString(), "Exception Found", MessageBoxButtons.OK);
            }
        }

        public void inc_alpha_num()
        {
            try
            {
                int p_len, x;
                string code = "";
                char[] letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray();
                p_len = int.Parse(comboBox1.SelectedItem.ToString());
                Random random = new Random();
                for (x = 0; x < p_len; x++)
                {
                    code += letter[random.Next(1, letter.Length)].ToString();
                }
                textBox1.Text = code.ToString();
            }
            catch (Exception Error)
            {
                MessageBox.Show(Error.ToString(), "Exception Found", MessageBoxButtons.OK);
            }
        }

        public void inc_alpha_spch()
        {
            try
            {
                int p_len, x;
                string code = "";
                char[] letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()".ToCharArray();
                p_len = int.Parse(comboBox1.SelectedItem.ToString());
                Random random = new Random();
                for (x = 0; x < p_len; x++)
                {
                    code += letter[random.Next(1, letter.Length)].ToString();
                }
                textBox1.Text = code.ToString();
            }
            catch (Exception Error)
            {
                MessageBox.Show(Error.ToString(), "Exception Found", MessageBoxButtons.OK);
            }
        }

        public void inc_num_spch()
        {
            try
            {
                int p_len, x;
                string code = "";
                char[] letter = "1234567890!@#$%^&*()".ToCharArray();
                p_len = int.Parse(comboBox1.SelectedItem.ToString());
                Random random = new Random();
                for (x = 0; x < p_len; x++)
                {
                    code += letter[random.Next(1, letter.Length)].ToString();
                }
                textBox1.Text = code.ToString();
            }
            catch (Exception Error)
            {
                MessageBox.Show(Error.ToString(), "Exception Found", MessageBoxButtons.OK);
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                checkBox3.Enabled = false;
                textBox1.ReadOnly = true;
                int i = 6;
                while (i < 26)
                {
                    comboBox1.Items.Add(i);
                    i++;
                }
            }
            catch (Exception Error)
            {
                MessageBox.Show(Error.ToString(), "Exception Found", MessageBoxButtons.OK);
            }
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                checkBox3.Enabled = true;
            }
            if (checkBox1.Checked == false && checkBox2.Checked == false)
            {
                checkBox3.Enabled = false;
            }
        }

        private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                checkBox3.Enabled = true;
            }
            if (checkBox1.Checked == false && checkBox2.Checked == false)
            {
                checkBox3.Enabled = false;
            }
        }
    }

}


---------------------------------------------------------------------------------------------------
Now run the project. . . .