private Bitmap GetDesktopBitmap()
{
         
           
  
                       
Size DesktopBitmapSize = GetDesktopBitmapSize();
Graphics Graphic = Graphics.FromHwnd(GetDesktopWindow());//从窗口的指定句柄创建新的 Graphics 对象
Bitmap MemImage = new Bitmap(DesktopBitmapSize.Width, DesktopBitmapSize.Height, Graphic);//生成图像
Graphics MemGraphic = Graphics.FromImage(MemImage);//从指定的 Image 对象创建新 Graphics 对象
IntPtr dc1 = Graphic.GetHdc();//获取与此 Graphics 对象关联的设备上下文的句柄
IntPtr dc2 = MemGraphic.GetHdc(); BitBlt(dc2, 0, 0, DesktopBitmapSize.Width, DesktopBitmapSize.Height, dc1, 0, 0, 0xCC0020);
            MemGraphic.DrawIcon( 这地方怎样写, Cursor.Position.X, Cursor.Position.Y);
              Graphic.ReleaseHdc(dc1);//释放通过以前对此 Graphics 对象的 GetHdc 方法的调用获得的设备上下文句柄
MemGraphic.ReleaseHdc(dc2);
Graphic.Dispose();
MemGraphic.Dispose();
return MemImage;
        }

解决方案 »

  1.   

    Cursor.Draw 方法public void Draw (
    Graphics g,
    Rectangle targetRect
    )
      

  2.   

    那怎样当前光标Cursor cur呢?
    怎样设置?
      

  3.   

    Rectangle   targetRect 
    怎样处理?
    没有直接在一点画的吗?
    用MemGraphic.DrawIcon(   这地方怎样写,   Cursor.Position.X,   Cursor.Position.Y); 怎样用?
      

  4.   

                Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                Graphics gs = Graphics.FromImage(bmp);
                Graphics gs1 = this.CreateGraphics();
                Cursor.Current.Draw(gs, new Rectangle(Cursor.Position.X - Cursor.Current.HotSpot.X, Cursor.Position.Y - Cursor.Current.HotSpot.Y, Cursor.Current.Size.Width, Cursor.Current.Size.Height));
                gs1.DrawImage(bmp, 0, 0);
                gs1.Dispose();
                gs.Dispose();
                bmp.Dispose();
      

  5.   

    new   Rectangle(Cursor.Position.X   -   Cursor.Current.HotSpot.X,   Cursor.Position.Y   -   Cursor.Current.HotSpot.Y,   Cursor.Current.Size.Width,   Cursor.Current.Size.Height); 
    要释放的!怎样释放?