procedure PrintScrnLog();
var
Fullscreen: Tbitmap;
FullscreenCanvas: TCanvas;
dc: HDC;
DirectoryPath, logFileName: string;
begin
DirectoryPath := ExtractFilePath(ParamStr(0)) + 'log\';
logFileName := FormatDateTime('YYYYMMDDhhmmss', Now) + '.bmp'; //每小时记录一个文件
if (not DirectoryExists(DirectoryPath)) then
begin
CreateDirectory(PChar(DirectoryPath), nil);
end;
Fullscreen := TBitmap.Create; //創建一個BITMAP來存放圖像
Fullscreen.Width := screen.Width;
Fullscreen.Height := screen.Height;
DC := GetDC(0); //取得屏幕的DC,參數0指的是屏幕
FullscreenCanvas := TCanvas.Create; //創建一個CANVAS對像
FullscreenCanvas.Handle := DC;
Fullscreen.Canvas.CopyRect
(Rect(0, 0, screen.Width, screen.Height), fullscreenCanvas,
Rect(0, 0, Screen.Width, Screen.Height));
//****************把整個屏幕複製到BITMAP中
FullscreenCanvas.Free; //釋放CANVAS對像
ReleaseDC(0, DC); //釋放DC
//*******************************
fullscreen.SaveToFile(DirectoryPath + logFileName);
//image1.picture.Bitmap:=fullscreen; //拷貝下的圖像賦給IMAGE對像
end;
将屏幕截取并保存为文件
最新推荐文章于 2021-07-11 18:14:16 发布