procedure ScreenCap();
const
WW=256;
HH=256;
var
BmpBits:Pointer;
FDeskHWnd:Hwnd;
SourceDC,DestDC,originHandel:integer;
i:Integer;
ABitmap:HBitmap;
s:TBitmap;
BmpInfHead:TBitmapInfoHeader;
Info : TBitMapInfo;
bits:Pointer;
Apointer:Pointer;
begin
//Create DIB
Info.bmiHeader.biSize := sizeof(BITMAPINFOHEADER);
Info.bmiHeader.biWidth := WW; //width
Info.bmiHeader.biHeight := HH; //height
Info.bmiHeader.biPlanes := 1;
Info.bmiHeader.biBitCount := 32;
Info.bmiHeader.biClrUsed := 0;
Info.bmiHeader.biCompression := BI_RGB;
Info.bmiHeader.biClrImportant := 0;
ABitmap := CreateDIBSection(SourceDC, Info, DIB_RGB_COLORS, APointer, 0, 0);
SourceDC:= GetDC(0);
DestDC:=CreateCompatibleDC(SourceDC);
ABitmap:=CreateCompatibleBitmap(SourceDC,WW,HH);
originHandel:=selectObject(DestDC,Abitmap);
BitBlt(DestDC,0,0,WW,HH,SourceDC,0,0,SRCCOPY);
GetDIBits(DestDC,Abitmap,0,480,Apointer,info,DIB_RGB_COLORS);
s :=TBitmap.Create;
s.Handle :=ABitmap;
selectObject(DestDC,originHandel);
s.SaveToFile('d:\q2.bmp');
DeleteDC(DestDC);
ReleaseDC(0,SourceDC);
end;
delphi截屏
最新推荐文章于 2023-10-09 17:23:22 发布