调用哪些类?最好有源代码~~
谢谢!!

解决方案 »

  1.   

    public   class   Win32APICall 

    [DllImport( "gdi32.dll ",EntryPoint= "DeleteDC ")] 
    public   static   extern   IntPtr   DeleteDC(IntPtr   hdc); [DllImport( "gdi32.dll ",EntryPoint= "DeleteObject ")] 
    public   static   extern   IntPtr   DeleteObject(IntPtr   hObject); [DllImport( "gdi32.dll ",EntryPoint= "BitBlt ")] 
    public   static   extern   bool   BitBlt(IntPtr   hdcDest,int   nXDest, 
    int   nYDest,int   nWidth,int   nHeight,IntPtr   hdcSrc, 
    int   nXSrc,int   nYSrc,int   dwRop); [DllImport   ( "gdi32.dll ",EntryPoint= "CreateCompatibleBitmap ")] 
    public   static   extern   IntPtr   CreateCompatibleBitmap(IntPtr   hdc,   
    int   nWidth,   int   nHeight); [DllImport   ( "gdi32.dll ",EntryPoint= "CreateCompatibleDC ")] 
    public   static   extern   IntPtr   CreateCompatibleDC(IntPtr   hdc); [DllImport   ( "gdi32.dll ",EntryPoint= "SelectObject ")] 
    public   static   extern   IntPtr   SelectObject(IntPtr   hdc,IntPtr   hgdiobjBmp); [DllImport( "user32.dll ",   EntryPoint= "GetDesktopWindow ")] 
    public   static   extern   IntPtr   GetDesktopWindow(); [DllImport( "user32.dll ",EntryPoint= "GetDC ")] 
    public   static   extern   IntPtr   GetDC(IntPtr   hWnd); [DllImport( "user32.dll ",EntryPoint= "GetSystemMetrics ")] 
    public   static   extern   int   GetSystemMetrics(int   nIndex); [DllImport( "user32.dll ",EntryPoint= "ReleaseDC ")] 
    public   static   extern   IntPtr   ReleaseDC(IntPtr   hWnd,IntPtr   hDC); public   static   Bitmap   GetDesktop() 

    int   screenX; 
    int   screenY; 
    IntPtr   hBmp; 
    IntPtr     hdcScreen   =   GetDC(GetDesktopWindow()); 
    IntPtr   hdcCompatible   =   CreateCompatibleDC(hdcScreen); screenX   =   GetSystemMetrics(0); 
    screenY   =   GetSystemMetrics(1); 
    hBmp   =   CreateCompatibleBitmap(hdcScreen,   screenX,   screenY); if   (hBmp!=IntPtr.Zero) 

    IntPtr   hOldBmp   =   (IntPtr)   SelectObject(hdcCompatible,   hBmp); 
    BitBlt(hdcCompatible,   0,   0,screenX,screenY,   hdcScreen,   0,   0,13369376); SelectObject(hdcCompatible,   hOldBmp); 
    DeleteDC(hdcCompatible); 
    ReleaseDC(GetDesktopWindow(),   hdcScreen); Bitmap   bmp   =   System.Drawing.Image.FromHbitmap(hBmp);   DeleteObject(hBmp); 
    GC.Collect(); return   bmp; 
    } return   null; 


    http://topic.csdn.net/u/20090324/08/ab0e7ec6-f5de-4612-969f-ce348017bd96.html
      

  2.   

    ////先创建图片
    //Bitmap bitmap = new Bitmap(
    //  Screen.PrimaryScreen.Bounds.Width,
    //  Screen.PrimaryScreen.Bounds.Height);////通过图片创建 Graphics
    //using (Graphics g = Graphics.FromImage(bitmap))
    //{
    //    //截屏
    //    g.CopyFromScreen(0, 0, 0, 0,
    //    bitmap.Size, CopyPixelOperation.SourceCopy);
    //    g.Save();
    //}通过图片取像素