Delphi取屏

var

  canvas: TCanvas;

  bmp:TBitmap;

  dwh:hWnd;

  dwd:HDC;

begin

  dwh:=GetDesktopWindow;

  dwd:=GetWindowDC(dwh);

  canvas:=TCanvas.Create;

  try

    canvas.Handle:=dwd;

    bmp:=TBitmap.Create;

    try

      bmp.Width := Screen.Width;

      bmp.Height := Screen.Height;

      bmp.Canvas.CopyRect(bmp.Canvas.ClipRect,canvas,bmp.Canvas.ClipRect);

      bmp.SaveToFile('f:\a.bmp');

    finally

 

      bmp.Free;

    end;

  finally

    canvas.Free;

  end;

end;

posted @ 2010-04-12 11:52  Max Woods  阅读(228)  评论(0编辑  收藏  举报