unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

//捕捉全屏幕图像并保存到: c:\temp\Screen.bmp
procedure TForm1.Button1Click(Sender: TObject);
var
  bit: TBitmap;
  DC: HDC;
  cvs: TCanvas;
begin
  bit := TBitmap.Create;
  bit.SetSize(Screen.Width, Screen.Height);

  DC := GetDC(0);
  cvs := TCanvas.Create;
  cvs.Handle := DC;

  bit.Canvas.CopyRect(Screen.DesktopRect, cvs, Screen.DesktopRect);
  bit.SaveToFile('c:\temp\Screen.bmp');

  ReleaseDC(0, DC);
  cvs.Free;
  bit.Free;
end;

end.

相关文章:

  • 2022-01-04
  • 2021-11-17
  • 2021-10-08
  • 2021-05-21
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2021-05-01
猜你喜欢
  • 2021-11-23
  • 2021-12-11
  • 2021-11-01
  • 2022-01-15
  • 2021-12-08
  • 2021-06-20
  • 2021-06-27
相关资源
相似解决方案