API:GetForegroundWindow获得前台窗口的句柄。这里的“前台窗口”是指前台应用程序的活动窗口
------------------------
[DllImport("user32.dll")]
private static extern int GetForegroundWindow();int iHnd=GetForegroundWindow();这个iHnd就是当前活动窗口的句柄了