Chương trình theo dõi màn hình máy tính
1 using System;
2 using System.Drawing;
3 using System.Drawing.Imaging;
4 using System.Collections;
5 using System.ComponentModel;
6 using System.Windows.Forms;
7 using System.Data;
8 using System.Runtime.Remoting; // gọi phương thức hỗ trợ Runtime.Remoting
9 using System.Runtime.Remoting.Channels;
10 using System.Runtime.Remoting.Channels.Tcp;
11
12 namespace Server
13 {
14
15
16 public class Form1 : System.Windows.Forms.Form
17 {
18 private System.Windows.Forms.Timer timer1;
19 private System.Windows.Forms.NotifyIcon notifyIcon1;
20 private System.Windows.Forms.ContextMenu contextMenu1;
21 private System.Windows.Forms.MenuItem menuItem1;
22 private System.ComponentModel.IContainer components;
23
24 public Form1()
25 {
26
27 InitializeComponent();
28 }
29
30
31 protected override void Dispose( bool disposing )
32 {
33 if( disposing )
34 {
35 if (components != null)
36 {
37 components.Dispose();
38 }
39 }
40 base.Dispose( disposing );
41 }
42
43 #region Windows Form Designer generated code
44 // Code trên để khoanh vùng tạo giao diện cho form
45 private void InitializeComponent()
46 {
47 this.components = new System.ComponentModel.Container();
48 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
49 this.timer1 = new System.Windows.Forms.Timer(this.components);
50 this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
51 this.contextMenu1 = new System.Windows.Forms.ContextMenu();
52 this.menuItem1 = new System.Windows.Forms.MenuItem();
53 this.SuspendLayout();
54 //
55 // timer1
56 //
57 this.timer1.Enabled = true;
58 this.timer1.Interval = 1;
59 this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
60 //
61 // notifyIcon1
62 //
63 this.notifyIcon1.ContextMenu = this.contextMenu1;
64 this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
65 this.notifyIcon1.Text = "Chương trình quản lý màn hình PC";
66 this.notifyIcon1.Visible = true;
67 //
68 // contextMenu1
69 //
70 this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
71 this.menuItem1});
72 //
73 // menuItem1
74 //
75 this.menuItem1.Index = 0;
76 this.menuItem1.Text = "Thoát chương trình";
77 this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
78 //
79 // Form1
80 //
81 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
82 this.ClientSize = new System.Drawing.Size(96, 32);
83 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
84 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
85 this.Name = "Form1";
86 this.Text = "Remotting Server";
87 this.Load += new System.EventHandler(this.Form1_Load);
88 this.ResumeLayout(false);
89
90 }
91 #endregion
92
93 // Chương trình chính
94 [STAThread]
95 static void Main()
96 {
97 Application.Run(new Form1());
98 }
99
100 private void Form1_Load(object sender, System.EventArgs e)
101 {
102
103 TcpChannel chan = new TcpChannel(6600);
104 ChannelServices.RegisterChannel(chan);
105 RemotingConfiguration.RegisterWellKnownServiceType(Type.GetType("ScreenCapture, ScreenCapture"), "MyCaptureScreenServer",WellKnownObjectMode.Singleton);
106
107 //Kênh được sử dụng để vận chuyển những thông báo tới bằng đối tượng triệu gọi từ xa.Khi một Client gọi phương thức trên đối tượng từ xa,
108 //các thông số, giống như chi tiết khác cái có liên quan tới tất cả thì truyền qua kênh tới đối tượng từ xa.
109 //Một vài kết quả trả từ về theo con đường mà client đã gọi.
110 }
111
112 private void menuItem5_Click(object sender, System.EventArgs e)
113 {
114 this.FormBorderStyle = FormBorderStyle.None;
115 this.WindowState = FormWindowState.Maximized;
116 }
117
118 private void timer1_Tick(object sender, System.EventArgs e)
119 {
120 this.Hide();
121 timer1.Enabled = false;
122 }
123
124
125 // Thoát chương trình ( có mật khẩu bảo vệ )
126 private void menuItem1_Click(object sender, System.EventArgs e)
127 {
128 String pass = Microsoft.VisualBasic.Interaction.InputBox("Nhập mật khẩu bảo vệ ", "Mật khẩu", "", -1, -1);
129 if (pass == "doanthephong") // Mật khẩu thoát chương trình
130 {
131 Application.Exit();
132 }
133 else
134 {
135 MessageBox.Show("Bạn đã nhập mật khẩu sai ! "," Lỗi");
136 }
137
138
139 }
140
141 }
142 }
2 using System.Drawing;
3 using System.Drawing.Imaging;
4 using System.Collections;
5 using System.ComponentModel;
6 using System.Windows.Forms;
7 using System.Data;
8 using System.Runtime.Remoting; // gọi phương thức hỗ trợ Runtime.Remoting
9 using System.Runtime.Remoting.Channels;
10 using System.Runtime.Remoting.Channels.Tcp;
11
12 namespace Server
13 {
14
15
16 public class Form1 : System.Windows.Forms.Form
17 {
18 private System.Windows.Forms.Timer timer1;
19 private System.Windows.Forms.NotifyIcon notifyIcon1;
20 private System.Windows.Forms.ContextMenu contextMenu1;
21 private System.Windows.Forms.MenuItem menuItem1;
22 private System.ComponentModel.IContainer components;
23
24 public Form1()
25 {
26
27 InitializeComponent();
28 }
29
30
31 protected override void Dispose( bool disposing )
32 {
33 if( disposing )
34 {
35 if (components != null)
36 {
37 components.Dispose();
38 }
39 }
40 base.Dispose( disposing );
41 }
42
43 #region Windows Form Designer generated code
44 // Code trên để khoanh vùng tạo giao diện cho form
45 private void InitializeComponent()
46 {
47 this.components = new System.ComponentModel.Container();
48 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
49 this.timer1 = new System.Windows.Forms.Timer(this.components);
50 this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
51 this.contextMenu1 = new System.Windows.Forms.ContextMenu();
52 this.menuItem1 = new System.Windows.Forms.MenuItem();
53 this.SuspendLayout();
54 //
55 // timer1
56 //
57 this.timer1.Enabled = true;
58 this.timer1.Interval = 1;
59 this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
60 //
61 // notifyIcon1
62 //
63 this.notifyIcon1.ContextMenu = this.contextMenu1;
64 this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
65 this.notifyIcon1.Text = "Chương trình quản lý màn hình PC";
66 this.notifyIcon1.Visible = true;
67 //
68 // contextMenu1
69 //
70 this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
71 this.menuItem1});
72 //
73 // menuItem1
74 //
75 this.menuItem1.Index = 0;
76 this.menuItem1.Text = "Thoát chương trình";
77 this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
78 //
79 // Form1
80 //
81 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
82 this.ClientSize = new System.Drawing.Size(96, 32);
83 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
84 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
85 this.Name = "Form1";
86 this.Text = "Remotting Server";
87 this.Load += new System.EventHandler(this.Form1_Load);
88 this.ResumeLayout(false);
89
90 }
91 #endregion
92
93 // Chương trình chính
94 [STAThread]
95 static void Main()
96 {
97 Application.Run(new Form1());
98 }
99
100 private void Form1_Load(object sender, System.EventArgs e)
101 {
102
103 TcpChannel chan = new TcpChannel(6600);
104 ChannelServices.RegisterChannel(chan);
105 RemotingConfiguration.RegisterWellKnownServiceType(Type.GetType("ScreenCapture, ScreenCapture"), "MyCaptureScreenServer",WellKnownObjectMode.Singleton);
106
107 //Kênh được sử dụng để vận chuyển những thông báo tới bằng đối tượng triệu gọi từ xa.Khi một Client gọi phương thức trên đối tượng từ xa,
108 //các thông số, giống như chi tiết khác cái có liên quan tới tất cả thì truyền qua kênh tới đối tượng từ xa.
109 //Một vài kết quả trả từ về theo con đường mà client đã gọi.
110 }
111
112 private void menuItem5_Click(object sender, System.EventArgs e)
113 {
114 this.FormBorderStyle = FormBorderStyle.None;
115 this.WindowState = FormWindowState.Maximized;
116 }
117
118 private void timer1_Tick(object sender, System.EventArgs e)
119 {
120 this.Hide();
121 timer1.Enabled = false;
122 }
123
124
125 // Thoát chương trình ( có mật khẩu bảo vệ )
126 private void menuItem1_Click(object sender, System.EventArgs e)
127 {
128 String pass = Microsoft.VisualBasic.Interaction.InputBox("Nhập mật khẩu bảo vệ ", "Mật khẩu", "", -1, -1);
129 if (pass == "doanthephong") // Mật khẩu thoát chương trình
130 {
131 Application.Exit();
132 }
133 else
134 {
135 MessageBox.Show("Bạn đã nhập mật khẩu sai ! "," Lỗi");
136 }
137
138
139 }
140
141 }
142 }