日期:2014-05-17 浏览次数:20837 次
namespace WpfApplication1
{
/// <summary>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
var desk = GetDesktopWindow();
var dc = GetDC(desk);
var pix = GetPixel(dc, 100, 200);
MessageBox.Show(pix.ToString());
}
public const string USER32 = "user32.dll";
[DllImport(USER32, EntryPoint = "GetDesktopWindow")]
public static extern IntPtr GetDesktopWindow();
[DllImport(USER32, EntryPoint = "GetDC", SetLastError = true)]
public static extern IntPtr GetDC(IntPtr hWnd);
[DllImport("gdi32.dll")]
public static extern uint GetPixel(IntPtr hWnd, int XPos, int YPos);
}
}