目的:抓取指定窗口的图像,即使该窗口被其他窗口遮盖。 代码: function shotscreen : tbitmap; var canvas : tcanvas; rect : trect; hwin : thandle; begin result := nil; hwin := getdistwindow;//找到目的窗体的handle if hwin = 0 then exit; getwindowrect(hwin,rect); with rect do begin right := right - left; bottom := bottom - top; left := 0; top := 0; end; result := bitmap;//全局定义 result.width := rect.right; result.height := rect.bottom; canvas := tcanvas.create; canvas.handle := getdc(hwin); result.canvas.copyrect(rect,canvas,rect); releasedc(hwin,canvas.handle); canvas.free; end;