Código Delphi
[-]
procedure Capturar(Filename: string);
var
SrcWindow: THandle;
SrcDC: HDC;
Bitmap: TBitmap;
Jpg: TJPEGImage;
begin
SrcWindow:= GetDesktopWindow;
if SrcWindow <> 0 then
begin
SrcDC:= GetDC(SrcWindow);
if SrcDC <> 0 then
begin
Bitmap:= TBitmap.Create;
Jpg:= TJPEGImage.Create;
try
Bitmap.Width:= GetSystemMetrics(SM_CXSCREEN);
Bitmap.Height:= GetSystemMetrics(SM_CYSCREEN);
BitBlt(Bitmap.Canvas.Handle,0,0,Bitmap.Width,Bitmap.Height,SrcDC,0,0,SRCCOPY);
Jpg.CompressionQuality:= 60;
Jpg.Assign(Bitmap);
Jpg.SaveToFile(Filename);
finally
Bitmap.Free;
Jpg.Free;
ReleaseDC(SrcWindow,SrcDC);
end;
end;
end;
end;
Ejemplo de uso:
Código Delphi
[-]
Capturar('d:\captura.jpg');