Guest User

Untitled

a guest
Apr 21st, 2010
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Microsoft.Win32;
  10. using System.IO;
  11. using System.Diagnostics;
  12.  
  13. namespace Windows_7_Logon_Changer
  14. {
  15.     public partial class Form1 : Form
  16.     {
  17.         public string fileName;
  18.         public Form1()
  19.         {
  20.             InitializeComponent();
  21.         }
  22.  
  23.         private void Form1_Load(object sender, EventArgs e)
  24.         {
  25.             string HDD = Environment.GetFolderPath(Environment.SpecialFolder.System).Replace("Windows\\system32", "");
  26.  
  27.             string HDD1 = HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\backgroundDefault.jpg";
  28.  
  29.             lblHeight.Text = "Height: " + SystemInformation.PrimaryMonitorSize.Height.ToString();
  30.  
  31.             lblWidth.Text = "Width: " + SystemInformation.PrimaryMonitorSize.Width.ToString();
  32.  
  33.             this.Text = "Windows 7 Logon Changer - " + Environment.UserName;
  34.  
  35.             RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI\\Background");
  36.  
  37.             string check = Convert.ToString(key.GetValue("OEMBackground"));
  38.  
  39.             if (check == "0")
  40.             {
  41.                 btnDisable.Enabled = false;
  42.                 btnDisable.Image = Windows_7_Logon_Changer.Properties.Resources.ye;
  43.                 btnDisable.ImageAlign = ContentAlignment.MiddleLeft;
  44.  
  45.                 btnEnable.Enabled = true;
  46.                 btnEnable.Image = null;
  47.  
  48.                 this.Width = 315;
  49.                 this.Height = 135;
  50.             }
  51.             else
  52.             {
  53.                 btnEnable.Enabled = false;
  54.                 btnEnable.Image = Windows_7_Logon_Changer.Properties.Resources.ye;
  55.                 btnEnable.ImageAlign = ContentAlignment.MiddleLeft;
  56.  
  57.                 btnDisable.Enabled = true;
  58.                 btnDisable.Image = null;
  59.  
  60.                 this.Width = 614;
  61.                 this.Height = 528;
  62.  
  63.                 pbBackground.ImageLocation = HDD1;
  64.             }
  65.         }
  66.  
  67.         private void btnEnable_Click(object sender, EventArgs e)
  68.         {
  69.             RegistryKey key = Registry.LocalMachine.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI\\Background");
  70.  
  71.             key.SetValue("OEMBackground", 1);
  72.  
  73.             btnEnable.Enabled = false;
  74.             btnEnable.Image = Windows_7_Logon_Changer.Properties.Resources.ye;
  75.             btnEnable.ImageAlign = ContentAlignment.MiddleLeft;
  76.  
  77.             btnDisable.Enabled = true;
  78.             btnDisable.Image = null;
  79.  
  80.             this.Width = 614;
  81.             this.Height = 528;
  82.  
  83.             Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.System).Replace("Windows\\system32", "") + "Windows\\System32\\oobe\\Info\\backgrounds\\");
  84.         }
  85.  
  86.         private void btnDisable_Click(object sender, EventArgs e)
  87.         {
  88.             RegistryKey key = Registry.LocalMachine.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI\\Background");
  89.  
  90.             key.SetValue("OEMBackground", 0);
  91.  
  92.             btnDisable.Enabled = false;
  93.             btnDisable.Image = Windows_7_Logon_Changer.Properties.Resources.ye;
  94.             btnDisable.ImageAlign = ContentAlignment.MiddleLeft;
  95.  
  96.             btnEnable.Enabled = true;
  97.             btnEnable.Image = null;
  98.  
  99.             this.Width = 315;
  100.             this.Height = 135;
  101.         }
  102.  
  103.         private void editInPaintToolStripMenuItem_Click(object sender, EventArgs e)
  104.         {
  105.             string HDD = Environment.GetFolderPath(Environment.SpecialFolder.System).Replace("Windows\\system32", "");
  106.  
  107.             string HDD1 = HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\backgroundDefault.jpg";
  108.  
  109.             Image img = Image.FromFile(HDD1);
  110.             img.Tag = HDD1;
  111.             System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
  112.             info.FileName = ("mspaint.exe");
  113.             info.Arguments = img.Tag.ToString();
  114.             System.Diagnostics.Process p1 = System.Diagnostics.Process.Start(info);
  115.         }
  116.  
  117.         private void addToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
  118.         {
  119.             Clipboard.SetImage(pbBackground.Image);
  120.         }
  121.  
  122.         private void btnChooseImage_Click(object sender, EventArgs e)
  123.         {
  124.             OpenFileDialog ofd = new OpenFileDialog();
  125.             ofd.Filter = "JPG Images (*.jpg)|*.jpg|JPEG Images (*.jpeg)|*.jpeg";
  126.             if (ofd.ShowDialog() == DialogResult.OK)
  127.             {
  128.                 string HDD = Environment.GetFolderPath(Environment.SpecialFolder.System).Replace("Windows\\system32", "");
  129.  
  130.                 string HDD1 = HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\backgroundDefault.jpg";
  131.  
  132.                 fileName = ofd.FileName;
  133.  
  134.                 PictureBox pbImage = new PictureBox();
  135.                 pbImage.ImageLocation = fileName;
  136.                 int Height = pbImage.Height;
  137.                 int Width = pbImage.Width;
  138.  
  139.                 FileInfo fi = new FileInfo(fileName);
  140.                 long fileSize = fi.Length;
  141.  
  142.                 if (fileSize > 262144)
  143.                 {
  144.                     MessageBox.Show("The Image can't be above 256kb's!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
  145.                     return;
  146.                 }
  147.  
  148.                 if (SystemInformation.PrimaryMonitorMaximizedWindowSize.Height > Height | SystemInformation.PrimaryMonitorMaximizedWindowSize.Width > Width)
  149.                 {
  150.                     if (MessageBox.Show("The Image is smaller than your screen! You can continue but it will be streched to fit your screen!" + Environment.NewLine + "Do you wish to continue?", "Error!", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.No)
  151.                     {
  152.                         return;
  153.                     }
  154.                 }
  155.                 btnNewImage.Enabled = true;
  156.  
  157.                 MessageBox.Show("Click 'Apply New Image' To make it the default new background", "Next Step", MessageBoxButtons.OK, MessageBoxIcon.Information);
  158.             }
  159.         }
  160.  
  161.         private void btnNewImage_Click(object sender, EventArgs e)
  162.         {
  163.             string HDD = Environment.GetFolderPath(Environment.SpecialFolder.System).Replace("Windows\\system32", "");
  164.  
  165.             string HDD1 = HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\backgroundDefault.jpg";
  166.  
  167.             try
  168.             {
  169.                 File.Delete(HDD1);
  170.             }
  171.             catch { }
  172.             HDD1.Replace("\\backgroundDefault.jpg", "");
  173.  
  174.             try
  175.             {
  176.                 File.Move(fileName, HDD1);
  177.             }
  178.             catch
  179.             {
  180.                 Directory.CreateDirectory(HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\");
  181.                 File.Move(fileName, HDD1);
  182.             }
  183.  
  184.             pbBackground.Image = null;
  185.             pbBackground.ImageLocation = HDD1;
  186.  
  187.             MessageBox.Show("New Backgroup Image Added, Log Off or Switch User to View it!", "Done!", MessageBoxButtons.OK, MessageBoxIcon.Information);
  188.         }
  189.  
  190.         private void btnAbout_Click(object sender, EventArgs e)
  191.         {
  192.             MessageBox.Show("Coded By: Call Me Alexx (Alex Reed)" +
  193.                 Environment.NewLine +
  194.                 "Originaly Found By: (Can't find who)" +
  195.                 Environment.NewLine +
  196.                 "Researched/Worked Out By: Call Me Alexx" +
  197.                 Environment.NewLine +
  198.                 Environment.NewLine +
  199.                 "Thanks To:" +
  200.                 Environment.NewLine +
  201.                 "HaLo2FrEaK - Idea after he made his application" +
  202.                 Environment.NewLine +
  203.                 "Dark Slipstream - Showing i converted bytes to kilobytes wrong, XD" +
  204.                 Environment.NewLine +
  205.                 "Roxy - <3" +
  206.                 Environment.NewLine +
  207.                 Environment.NewLine +
  208.                 "Warning: This computer program is protected by international treaties. Blargy, Blargy, Blarg... Just don't be a gypsy and steal it or the sauce code. :)" +
  209.                 Environment.NewLine +
  210.                 "kthxbai. ;D",
  211.                 "Windows 7 Logon Changer - About",
  212.                 MessageBoxButtons.OK,
  213.                 MessageBoxIcon.Information);
  214.         }
  215.  
  216.         private void btnSupImages_Click(object sender, EventArgs e)
  217.         {
  218.             if (tabControl1.Visible == false)
  219.             {
  220.                 tabControl1.Visible = true;
  221.                 tabControl1.BringToFront();
  222.             }
  223.             else
  224.             {
  225.                 tabControl1.Visible = false;
  226.                 tabControl1.SendToBack();
  227.             }
  228.         }
  229.  
  230.         private void pB1_MouseDoubleClick(object sender, MouseEventArgs e)
  231.         {
  232.             string HDD = Environment.GetFolderPath(Environment.SpecialFolder.System).Replace("Windows\\system32", "");
  233.  
  234.             string HDD1 = HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\backgroundDefault.jpg";
  235.  
  236.             try { Windows_7_Logon_Changer.Properties.Resources.pB1.Save(HDD1); }
  237.             catch
  238.             {
  239.                 Directory.CreateDirectory(HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\");
  240.                 Windows_7_Logon_Changer.Properties.Resources.pB1.Save(HDD1);
  241.             }
  242.  
  243.             pbBackground.Image = null;
  244.             pbBackground.ImageLocation = HDD1;
  245.  
  246.             MessageBox.Show("New Backgroup Image Added, Log Off or Switch User to View it!", "Done!", MessageBoxButtons.OK, MessageBoxIcon.Information);
  247.         }
  248.  
  249.         private void pB2_MouseDoubleClick(object sender, MouseEventArgs e)
  250.         {
  251.             string HDD = Environment.GetFolderPath(Environment.SpecialFolder.System).Replace("Windows\\system32", "");
  252.  
  253.             string HDD1 = HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\backgroundDefault.jpg";
  254.  
  255.             try { Windows_7_Logon_Changer.Properties.Resources.pB2.Save(HDD1); }
  256.             catch
  257.             {
  258.                 Directory.CreateDirectory(HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\");
  259.                 Windows_7_Logon_Changer.Properties.Resources.pB2.Save(HDD1);
  260.             }
  261.  
  262.             pbBackground.Image = null;
  263.             pbBackground.ImageLocation = HDD1;
  264.  
  265.             MessageBox.Show("New Backgroup Image Added, Log Off or Switch User to View it!", "Done!", MessageBoxButtons.OK, MessageBoxIcon.Information);
  266.         }
  267.  
  268.         private void tabControl1_Leave(object sender, EventArgs e)
  269.         {
  270.             tabControl1.Visible = false;
  271.             tabControl1.SendToBack();
  272.         }
  273.  
  274.         private void pB3_MouseDoubleClick(object sender, MouseEventArgs e)
  275.         {
  276.             string HDD = Environment.GetFolderPath(Environment.SpecialFolder.System).Replace("Windows\\system32", "");
  277.  
  278.             string HDD1 = HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\backgroundDefault.jpg";
  279.  
  280.             try { Windows_7_Logon_Changer.Properties.Resources.pB3.Save(HDD1); }
  281.             catch
  282.             {
  283.                 Directory.CreateDirectory(HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\");
  284.                 Windows_7_Logon_Changer.Properties.Resources.pB3.Save(HDD1);
  285.             }
  286.  
  287.             pbBackground.Image = null;
  288.             pbBackground.ImageLocation = HDD1;
  289.  
  290.             MessageBox.Show("New Backgroup Image Added, Log Off or Switch User to View it!", "Done!", MessageBoxButtons.OK, MessageBoxIcon.Information);
  291.         }
  292.  
  293.         private void pB4_MouseDoubleClick(object sender, MouseEventArgs e)
  294.         {
  295.             string HDD = Environment.GetFolderPath(Environment.SpecialFolder.System).Replace("Windows\\system32", "");
  296.  
  297.             string HDD1 = HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\backgroundDefault.jpg";
  298.  
  299.             try { Windows_7_Logon_Changer.Properties.Resources.pB4.Save(HDD1); }
  300.             catch
  301.             {
  302.                 Directory.CreateDirectory(HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\");
  303.                 Windows_7_Logon_Changer.Properties.Resources.pB4.Save(HDD1);
  304.             }
  305.  
  306.             pbBackground.Image = null;
  307.             pbBackground.ImageLocation = HDD1;
  308.  
  309.             MessageBox.Show("New Backgroup Image Added, Log Off or Switch User to View it!", "Done!", MessageBoxButtons.OK, MessageBoxIcon.Information);
  310.         }
  311.  
  312.         private void pB5_MouseDoubleClick(object sender, MouseEventArgs e)
  313.         {
  314.             string HDD = Environment.GetFolderPath(Environment.SpecialFolder.System).Replace("Windows\\system32", "");
  315.  
  316.             string HDD1 = HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\backgroundDefault.jpg";
  317.  
  318.             try { Windows_7_Logon_Changer.Properties.Resources.pB5.Save(HDD1); }
  319.             catch
  320.             {
  321.                 Directory.CreateDirectory(HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\");
  322.                 Windows_7_Logon_Changer.Properties.Resources.pB5.Save(HDD1);
  323.             }
  324.  
  325.             pbBackground.Image = null;
  326.             pbBackground.ImageLocation = HDD1;
  327.  
  328.             MessageBox.Show("New Backgroup Image Added, Log Off or Switch User to View it!", "Done!", MessageBoxButtons.OK, MessageBoxIcon.Information);
  329.         }
  330.  
  331.         private void pB6_MouseDoubleClick(object sender, MouseEventArgs e)
  332.         {
  333.             string HDD = Environment.GetFolderPath(Environment.SpecialFolder.System).Replace("Windows\\system32", "");
  334.  
  335.             string HDD1 = HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\backgroundDefault.jpg";
  336.  
  337.             try { Windows_7_Logon_Changer.Properties.Resources.pB6.Save(HDD1); }
  338.             catch
  339.             {
  340.                 Directory.CreateDirectory(HDD + "Windows\\System32\\oobe\\Info\\backgrounds\\");
  341.                 Windows_7_Logon_Changer.Properties.Resources.pB6.Save(HDD1);
  342.             }
  343.             pbBackground.Image = null;
  344.             pbBackground.ImageLocation = HDD1;
  345.  
  346.             MessageBox.Show("New Backgroup Image Added, Log Off or Switch User to View it!", "Done!", MessageBoxButtons.OK, MessageBoxIcon.Information);
  347.         }
  348.     }
  349. }
Advertisement
Add Comment
Please, Sign In to add comment