微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

delphi截屏

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);
 SourceDC:= GetDC(0);
 DestDC:=CreateCompatibleDC(SourceDC);
 ABitmap:=CreateCompatibleBitmap(SourceDC,WW,HH);
 originHandel:=selectObject(DestDC,Abitmap);
 BitBlt(DestDC,HH,SourceDC,SRCcopY);
 GetDIBits(DestDC,Abitmap,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;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐