using Microsoft.Win32;
起始位置: WindowsDefaultLocation
regedit
1: private void Form1_Load(object sender, EventArgs e)
2: {
3: RegistryKey rkey1, rkey2; //宣告註冊表物件
4: rkey1 = Registry.CurrentUser; //取得目前用戶註冊表項
5: try
6: {
7: rkey2 = rkey1.CreateSubKey("Software\\MySoft");
8: this.Location = new Point( Convert.ToInt16(rkey2.GetValue("x")), Convert.ToInt16(rkey2.GetValue("y")) );
9: }
10: catch(Exception exc)
11: {
12: MessageBox.Show(exc.ToString());
13: }
14: }
15:
16: private void Form1_FormClosed(object sender, FormClosedEventArgs e)
17: {
18: RegistryKey rkey1, rkey2;
19: rkey1 = Registry.CurrentUser;
20: try
21: {
22: rkey2 = rkey1.CreateSubKey("Software\\MySoft");
23: rkey2.SetValue("x", this.Location.X.ToString());
24: rkey2.SetValue("y", this.Location.Y.ToString());
25: }
26: catch
27: {
28: }
29: }
全站熱搜
留言列表