我是使用Bitblt进行截图,主要代码如下
  if iTempWnd=0 then iTempWnd:=GetDeskTopWindow;
  iDC:=GetDC(iTempWnd);    //Get desktop window's DC
  try
    Abmp.Width:=x2-x1+1;
    Abmp.Height:=y2-y1+1;
    //Bitblt the picture of the windows that the cursor on it
    //to the tmpBitmap to be oprating
    Bitblt(Abmp.Canvas.Handle,0,0,Abmp.Width,ABmp.Height,iDC,x1,y1,SRCCOPY);
    Abmp.PixelFormat:=pf24bit;
  finally
    ReleaseDC(iTempWnd,iDC);
  end;程序中会间隔一段不一定相同的时间就调用这段代码进行1024*768大小的截图,调试中隔几个小时后就会提示系统资源不足,然后程序停在Bitblt后面一句语句。网上查资料似乎是Bitblt会导致内存缓冲无法完全释放,有什么办法释放掉这些内存或者用其他语句代替这个?