2013年8月14日

获取本机可用端口

摘要: 如下:using System;using System.Collections.Generic;using System.Linq;using System.Net.NetworkInformation;namespace ConsoleApplication2{ public static class AvailablePort { /// public static int GetFirstAvailablePort() { const int MAX_PORT = 65535; cons... 阅读全文

posted @ 2013-08-14 20:07 yao2yao4 阅读(356) 评论(0) 推荐(0) 编辑

textbox的验证

摘要: 代码如下:textBox1.KeyDown += (a, b) => { if (b.KeyCode == Keys.Enter) { textBox2.Focus(); } };textBox1.Leave += delegate { int result; if (!int.TryParse(textBox1.Text.Trim(), out result)) { MessageBox.Show("fsfd"); textB... 阅读全文

posted @ 2013-08-14 07:17 yao2yao4 阅读(298) 评论(0) 推荐(0) 编辑

鼠标和键盘操作的全局钩子库

摘要: 注意只能用于AnyCPU、.NET版本一致、只能用于Winform。简化后的代码如下:using System;using System.ComponentModel;using System.Reflection;using System.Runtime.InteropServices;using System.Windows.Forms;namespace UserActivityMonitor{ /// /// This class monitors all mouse activities globally (also outside of the application... 阅读全文

posted @ 2013-08-14 06:46 yao2yao4 阅读(696) 评论(0) 推荐(0) 编辑

导航