回首我的六级心路历程,真是气壮山河啊。。。不过功夫不负有心人,这次真是应了一句话Impossible is Nothing!
Ping MM:Request timed out;
Ping money:Destination unreachable;
Ping Love:Unkown host name;
Ping Future:Reply from hell: bytes=32 time=99year TTL=1
<P><A href="http://wpa.qq.com/msgrd?V=1&Uin=137673&Site=www.felixwoo.com&Menu=yes" target=blank><IMG alt=点击这里给我发消息 src="http://wpa.qq.com/pa?p=1:137673:11" border=0></A> </P>
<P><A href="http://wpa.qq.com/msgrd?V=1&Uin=137673&Site=www.felixwoo.com&Menu=yes" target=blank><IMG alt=点击这里给我发消息 src="http://wpa.qq.com/pa?p=1:137673:1" border=0></A> </P>
<P>这是QQ最新的查看在线状态功能,可以直接从图标知道我是否在线,而且可以点击图标给我留言。</P>
1. we two who and who?
咱俩谁跟谁阿
2. how are you ? how old are you?
怎么是你,怎么老是你?
3. you don't bird me,I don't bird you
你不鸟我,我也不鸟你
4. you have seed I will give you some color to see see, brothers !together
你有种,我要给你点颜色瞧瞧,兄弟们,一起上!
5. hello everybody!if you have something to say,then say!if you have
nothing to say,go home!!
有事起奏,无事退朝
6.what is IMU3.0? it is a kind of chat tool!
什么是IMU3。0?IMU3.0 是一种聊天工具!
7. You Give Me Stop!!
你给我站住!
8. know is know noknow is noknow
知之为知之,不知为不知…
9. WATCH SISTER
表妹
10. IMU3。0 both can do what???
IMU上直接查找和添加QQ、MSN好友。在2.6版本中,IMU虽然兼容了QQ和MSN,但纯粹是把QQ、MSN的用户群绑定在IMU界面上,既不能添加好友也不能互发文件,造成许多不便。现在,3.0终于做到了完全兼容,以后只要打开IMU3.0,所有聊天工具一网打尽。
11. American Chinese not enough
美中不足
13. heart flower angry open
心花怒放
14. go past no mistake past
走过路过,不要错过
15. 小明:I am sorry!
老外:I am sorry too!
小明:I am sorry three!
老外:What are you sorry for?
小明:I am sorry five!
16. If you want money,I have no;if you want life,I have one!
要钱没有,要命一条
17. I call Li old big. toyear 25.
我叫李老大,今年25。
18. you have two down son。
你有两下子。
19. as far as you go to die
有多远,死多远!!!!
20. I give you face you don't want face,you lose you face ,I turn my face.
给你脸你不要脸,你丢脸,我翻脸
<P>欢迎大家访问我的FTP,我最新压制的RMVB电影都会发布在上面,地址是<A href="ftp://www.felixwoo.com">ftp://www.felixwoo.com</A>,下载的用户名和密码都是felix。</P><div align=right class=eng style=color:#cccccc>[Edit on 2005-1-3 1:42:44 By Felix]</div>
一位优秀的商人杰克,有一天告诉他的儿子——
杰克:我已经决定好了一个女孩子,我要你娶她。
儿子:我自己要娶的新娘我自己会决定。
杰克:但我说的这女孩可是比尔盖兹的女儿喔!
儿子:哇!那这样的话……
在一个聚会中,杰克走向比尔盖茨——
杰克:我来帮你女儿介绍个好丈夫。
比尔:我女儿还没想嫁人呢!
杰克:但我说的这年轻人可是世界银行的副总裁喔!
比尔:哇!那这样的话……
接着,杰克去见世界银行的总裁——
杰克:我想介绍一位年轻人来当贵行的副总裁。
总裁:我们已经有很多位副总裁,够多了。
杰克:但我说的这年轻人可是比尔盖兹的女婿喔!
总裁:哇!那这样的话……
最后,杰克的儿子娶了比尔盖茨的女儿,又当上世界银行的副总裁。
一、最小化窗口
点击“X”或“Alt+F4”时,最小化窗口,
如:
protected override void WndProc(ref Message m)
{
const int WM_SYSCOMMAND = 0x0112;
const int SC_CLOSE = 0xF060;
if (m.Msg == WM_SYSCOMMAND && (int) m.WParam == SC_CLOSE)
{
// User clicked close button
this.WindowState = FormWindowState.Minimized;
return;
}
base.WndProc(ref m);
}
二、如何让Foreach 循环运行的更快
foreach是一个对集合中的元素进行简单的枚举及处理的现成语句,用法如下例所示:
using System;
using System.Collections;
namespace LoopTest
{
class Class1
{
static void Main(string[] args)
{
// create an ArrayList of strings
ArrayList array = new ArrayList();
array.Add("Marty");
array.Add("Bill");
array.Add("George");
// print the value of every item
foreach (string item in array)
{
Console.WriteLine(item);
}
}
}
你可以将foreach语句用在每个实现了Ienumerable接口的集合里。如果想了解更多foreach的用法,你可以查看.NET Framework SDK文档中的C# Language Specification。
在编译的时候,C#编辑器会对每一个foreach 区域进行转换。IEnumerator enumerator = array.GetEnumerator();
try
{
string item;
while (enumerator.MoveNext())
{
item = (string) enumerator.Current;
Console.WriteLine(item);
}
}
finally
{
IDisposable d = enumerator as IDisposable;
if (d != null) d.Dispose();
}
这说明在后台,foreach的管理会给你的程序带来一些增加系统开销的额外代码。
三、将图片保存到一个XML文件
WinForm的资源文件中,将PictureBox的Image属性等非文字内容都转变成文本保存,这是通过序列化(Serialization)实现的,
例子://
using System.Runtime.Serialization.Formatters.Soap;
Stream stream = new FileStream("E:\\Image.xml",FileMode.Create,FileAccess.Write,FileShare.None);
SoapFormatter f = new SoapFormatter();
Image img = Image.FromFile("E:\\Image.bmp");
f.Serialize(stream,img);
stream.Close();
四、屏蔽CTRL-V
在WinForm中的TextBox控件没有办法屏蔽CTRL-V的剪贴板粘贴动作,如果需要一个输入框,但是不希望用户粘贴剪贴板的内容,可以改用RichTextBox控件,并且在KeyDown中屏蔽掉CTRL-V键,例子:
private void richTextBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.Control && e.KeyCode==Keys.V)
e.Handled = true;
}
一、判断文件或文件夹是否存在
使用System.IO.File,要检查一个文件是否存在非常简单:
bool exist = System.IO.File.Exists(fileName);
如果需要判断目录(文件夹)是否存在,可以使用System.IO.Directory:
bool exist = System.IO.Directory.Exists(folderName);
二、使用delegate类型设计自定义事件
在C#编程中,除了Method和Property,任何Class都可以有自己的事件(Event)。定义和使用自定义事件的步骤如下:
(1)在Class之外定义一个delegate类型,用于确定事件程序的接口
(2)在Class内部,声明一个public event变量,类型为上一步骤定义的delegate类型
(3)在某个Method或者Property内部某处,触发事件
(4)Client程序中使用+=操作符指定事件处理程序
例子: // 定义Delegate类型,约束事件程序的参数
public delegate void MyEventHandler(object sender, long lineNumber) ;
public class DataImports
{
// 定义新事件NewLineRead
public event MyEventHandler NewLineRead ;
public void ImportData()
{
long i = 0 ; // 事件参数
while()
{
i++ ;
// 触发事件
if( NewLineRead != null ) NewLineRead(this, i);
//...
}
//...
}
//...
}
// 以下为Client代码
private void CallMethod()
{
// 声明Class变量,不需要WithEvents
private DataImports _da = null;
// 指定事件处理程序
_da.NewLineRead += new MyEventHandler(this.DA_EnterNewLine) ;
// 调用Class方法,途中会触发事件
_da.ImportData();
}
// 事件处理程序
private void DA_EnterNewLine(object sender, long lineNumber)
{
// ...
}
三、IP与主机名解析
使用System.Net可以实现与Ping命令行类似的IP解析功能,例如将主机名解析为IP或者反过来: private string GetHostNameByIP(string ipAddress)
{
IPHostEntry hostInfo = Dns.GetHostByAddress(ipAddress);
return hostInfo.HostName;
}
private string GetIPByHostName(string hostName)
{
System.Net.IPHostEntry hostInfo = Dns.GetHostByName(hostName);
return hostInfo.AddressList[0].ToString();
}
In some scenarios, you may wish to ensure that a user can run only one instance of your application at a time. Besides ensuring that only a single instance of your application is running, you may also want to bring the instance already running to the front and restore it, if it is minimized.
First, to ensure that only one instance of your application is running at a time, the best method I've found is to create a mutex that is held by the operating system (thanks to Michael Covington). This will put a request to the operating system that a mutex be created if one does not already exist. Only one mutex can ever be created at a time, so if you request a new one and it cannot be created, you can safely assume that your application is already running.
using System.Threading
using System.Runtime.InteropServices;
public class Form1 : Form
{
[STAThread]
static void Main()
{
bool createdNew;
Mutex m = new Mutex(true, "YourAppName", out createdNew);
if (! createdNew)
{
// app is already running...
MessageBox.Show("Only one instance of this application is allowed at a time.");
return;
}
Application.Run(new Form1());
// keep the mutex reference alive until the normal termination of the program
GC.KeepAlive(m);
}
}
The above code will work for the vast majority of your needs. It will also run under scenarios where your code is executing with less than FullTrust permissions (see Code Access Security in MSDN for further information).
If your application can run with Full Trust permissions, we can take this a step further and find the window of the application instnace already running and bring it to the front for the user:
public class Form1 : Form
{
[STAThread]
static void Main()
{
bool createdNew;
System.Threading.Mutex m = new System.Threading.Mutex(true, "YourAppName", out createdNew);
if (! createdNew)
{
// see if we can find the other app and Bring it to front
IntPtr hWnd = FindWindow("WindowsForms10.Window.8.app3", "YourAppName");
if(hWnd != IntPtr.Zero)
{
Form1.WINDOWPLACEMENT placement = new Form1.WINDOWPLACEMENT();
placement.length = Marshal.SizeOf(placement);
GetWindowPlacement(hWnd, ref placement);
if(placement.showCmd != SW_NORMAL)
{
placement.showCmd = SW_RESTORE;
SetWindowPlacement(hWnd, ref placement);
SetForegroundWindow(hWnd);
}
}
return;
}
Application.Run(new Form1());
// keep the mutex reference alive until the normal termination of the program
GC.KeepAlive(m);
}
private const int SW_NORMAL = 1; // see WinUser.h for definitions
private const int SW_RESTORE = 9;
[DllImport("User32",EntryPoint="FindWindow")]
static extern IntPtr FindWindow(string className, string windowName);
[DllImport("User32",EntryPoint="SendMessage")]
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("User32",EntryPoint="SetForegroundWindow")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("User32",EntryPoint="SetWindowPlacement")]
private static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref WINDOWPLACEMENT lpwndpl);
[DllImport("User32",EntryPoint="GetWindowPlacement")]
private static extern bool GetWindowPlacement(IntPtr hWnd, [In] ref WINDOWPLACEMENT lpwndpl);
private struct POINTAPI
{
public int x;
public int y;
}
private struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
private struct WINDOWPLACEMENT
{
public int length;
public int flags;
public int showCmd;
public POINTAPI ptMinPosition;
public POINTAPI ptMaxPosition;
public RECT rcNormalPosition;
}
}
As you can see, with minimal effort, you can easily add a polished touch to your application. This might even help you avoid some extra legwork in ensuring that there are no issues with running multiple instances of your app at the same time that you might have to address.
For more information about the Platform Invoke mechanisms to call Win32 API functions, I recommend that you check out .NET Framework Solutions: In Search of the Lost Win32 API by John Mueller and Charles Petzold's seminal classic Programming Windows.
Until Longhorn comes out and more of the Windows platform becomes managed, platform invokes and interop will remain a key technology to understand and use to your advantage to fill the gaps left by the Windows Forms framework.
UPDATE:
Visual Studio .NET 2005 (aka. “Whidbey”) will let you specify Single Instance behavior for Visual Basic .NET projects through the Project Properties page. Curious as to why this option is available for VB projects and not for C# projects, as this seems to instruct the runtime or some framework library not to load more than one instance.














