using Microsoft.Win32;
void SaveSettings()
{
RegistryKey SoftwareKey = Registry.LocalMachine.OpenSubKey("Software", true);
RegistryKey MovecontKey = SoftwareKey.CreateSubKey("Movecont");
RegistryKey SelfPlaceKey = MovecontKey.CreateSubKey("SelfPlace");
SelfPlaceKey.SetValue("BackColor", (object)BackColor.ToKnownColor());
SelfPlaceKey.SetValue("Red", (object)(int)BackColor.R);
SelfPlaceKey.SetValue("Green", (object)(int)BackColor.G);
SelfPlaceKey.SetValue("Blue", (object)(int)BackColor.B);
SelfPlaceKey.SetValue("Width", (object)Width);
SelfPlaceKey.SetValue("Height", (object)Height);
SelfPlaceKey.SetValue("X", (object)DesktopLocation.X);
SelfPlaceKey.SetValue("Y", (object)DesktopLocation.Y);
SelfPlaceKey.SetValue("WindowState", (object)WindowState.ToString());
}
bool ReadSettings()
{
RegistryKey SoftwareKey = Registry.LocalMachine.OpenSubKey("Software", true);
RegistryKey MovecontKey = SoftwareKey.OpenSubKey("Movecont");
if (MovecontKey == null)
return false;
RegistryKey SelfPlaceKey = MovecontKey.OpenSubKey("SelfPlace");
if (SelfPlaceKey == null)
return false;
else
this.listBoxMessages.Items.Add("成功打开注册表!");
int Red = (int)SelfPlaceKey.GetValue("Red");
int Green = (int)SelfPlaceKey.GetValue("Green");
int Blue = (int)SelfPlaceKey.GetValue("Blue");
BackColor = Color.FromArgb(Red, Green, Blue);
this.listBoxMessages.Items.Add("Backcolor Name:" + BackColor.Name);
int X = (int)SelfPlaceKey.GetValue("X");
int Y = (int)SelfPlaceKey.GetValue("Y");
DesktopLocation = new Point(X, Y);
this.listBoxMessages.Items.Add("Location:" + DesktopLocation.ToString());
Width = (int)SelfPlaceKey.GetValue("Width");
Height = (int)SelfPlaceKey.GetValue("Height");
this.listBoxMessages.Items.Add("Size:" + new Size(Width, Height).ToString());
string Initstate = (string)SelfPlaceKey.GetValue("WindowState");
WindowState = (FormWindowState)FormWindowState.Parse(WindowState.GetType(), Initstate);
return true;
}