http://www.oschina.net/code/snippet_119226_5833
[代码] [C#]代码
001 | 1. StreamWriter - 文件写入类 |
002 | StreamWriter s = new StreamWriter(address + "/Menu.ini" , true ); |
003 | s.WriteLine(openFileDialog1.FileName); |
007 | 2. StreamReader - 文件读取类 |
008 | StreamReader sr = new StreamReader(address + "/Menu.ini" ); |
011 | string str = sr.ReadLine(); |
016 | Image p = Image.FromFile( "/背景图片.jpg" ); |
019 | f.BackgroundImage = p; |
025 | bit = new Bitmap( "heart.bmp" ); |
026 | bit.MakeTransparent(Color.White); |
028 | protected override void OnPaint(PaintEventArgs e) |
031 | e.Graphics.DrawImage((Image)bit, new Point(0, 0)); |
034 | 5. this .Opacity - 控件的不透明度 |
038 | [System.Runtime.InteropServices.DllImportAttribute( "user32.dll" )] |
039 | public static extern bool FlashWindow(IntPtr handle, bool bInvert); |
042 | this .ControlBox = false ; |
048 | Screen.PrimaryScreen.WorkingArea.Height |
049 | Screen.PrimaryScreen.WorkingArea.Width |
050 | Screen.PrimaryScreen.BitsPerPixel |
055 | Pen myPen = new Pen(Color.Blue, 2); |
058 | graphics = this .CreateGraphics(); |
059 | graphics.DrawLine(myPen, 30, 60, 150, 60); |
062 | graphics = this .CreateGraphics(); |
063 | graphics.DrawRectangle(myPen, 30, 80, 120, 50); |
066 | graphics = this .CreateGraphics(); |
067 | Rectangle myRectangle = new Rectangle(160, 70, 100, 60); |
068 | graphics.DrawEllipse(myPen, myRectangle); |
071 | Cursor.Clip = new Rectangle( this .Location, this .Size); |
072 | label1.Text = "当前鼠标的位置为:" + Cursor.Position; |
075 | protected override bool ProcessCmdKey( ref Message msg, Keys keyData) |
077 | const int WM_KEYDOWN = 0x100; |
078 | const int WM_SYSKEYDOWN = 0x104; |
079 | string strInfo = string .Empty; |
080 | if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN)) |
085 | strInfo = "Down Key" ; |
091 | strInfo = "Left Key" ; |
094 | strInfo = "Right Key" ; |
097 | strInfo = "Home Key" ; |
103 | MessageBox.Show(strInfo, "信息" , MessageBoxButtons.OK, MessageBoxIcon.Information); |
105 | return base .ProcessCmdKey( ref msg, keyData); |
110 | private void CloseComputer( string strname, string strpwd, string ip, string doinfo) |
112 | ConnectionOptions op = new ConnectionOptions ( ) ; |
113 | op.Username =strname; |
114 | op.Password = strpwd; |
115 | ManagementScope scope = new ManagementScope( "" + ip + "//root//cimv2:Win32_Service" , op); |
119 | System.Management.ObjectQuery oq = new System.Management.ObjectQuery ( "SELECT * FROM Win32_OperatingSystem" ) ; |
120 | ManagementObjectSearcher query1 = new ManagementObjectSearcher (scope,oq) ; |
122 | ManagementObjectCollection queryCollection1 = query1.Get ( ) ; |
123 | foreach ( ManagementObject mobj in queryCollection1 ) |
125 | string [ ] str= { "" } ; |
126 | mobj.InvokeMethod(doinfo, str); |
128 | MessageBox.Show( "操作成功" ); |
132 | MessageBox.Show(ey.Message); |
138 | CloseComputer( this .textBox2.Text, this .textBox3.Text, this .textBox1.Text, "Reboot" ); |
141 | CloseComputer( this .textBox2.Text, this .textBox3.Text, this .textBox1.Text, "Shutdown" ); |
144 | Ping PingInfo = new Ping(); |
145 | PingOptions PingOpt = new PingOptions(); |
146 | PingOpt.DontFragment = true ; |
147 | string myInfo = "hyworkhyworkhyworkhyworkhyworkhywork" ; |
148 | byte [] bufferInfo = Encoding.ASCII.GetBytes(myInfo); |
150 | PingReply reply = PingInfo.Send( this .textBox1.Text, TimeOut, bufferInfo, PingOpt); |
151 | if (reply.Status == IPStatus.Success) |
153 | this .textBox2.Text = reply.RoundtripTime.ToString(); |
154 | this .textBox3.Text = reply.Options.Ttl.ToString(); |
155 | this .textBox4.Text = (reply.Options.DontFragment ? "发生分段" : "没有发生分段" ); |
156 | this .textBox5.Text = reply.Buffer.Length.ToString(); |
160 | MessageBox.Show( "无法Ping通" ); |
164 | public int CheckFileExit( string ObjFilePath) |
166 | if (File.Exists(ObjFilePath)) |