实现效果:
知识运用:
Form类的Size Location属性
Registry类的SetValue方法
知识运用:
private void Form1_Load(object sender, EventArgs e) { label1.Text = "窗体大小: "+this.Size.ToString(); label2.Text = "窗体位置: "+this.Location.ToString(); } private void button1_Click(object sender, EventArgs e) { try { Registry.CurrentUser.CreateSubKey("SubKey\\Key").SetValue("窗体大小:",this.Size.ToString()); Registry.SetValue(@"HKEY_CURRENT_USER\\SubKey\\Key","窗体位置:",this.Location.ToString()); MessageBox.Show("信息保存成功!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }