下面这段代码是截图用的!每30秒运行一次,一个半小时后程序出现非法操作,不知道是什么原因,望高手指正!<br>procedure TgetBmp.Get(x1, y1, x2, y2: Word;FileName:string);<br>var MyDC:HDC;<br> Mycanvas:TCanvas;<br> rect1,rect2:TRect;<br>begin<br><br><br> MyDC:=createdc('display','','',nil);<br> MyBmp:=TBitmap.Create;<br> mybmp.Height:=35;<br> mybmp.Width:=35;<br> Mycanvas:=TCanvas.Create;<br> myCanvas.Handle:=MyDC;<br> rect1.TopLeft.X:=x1;<br> rect1.TopLeft.Y:=y1;<br> rect1.BottomRight.X:=x2;<br> rect1.BottomRight.Y:=y2;<br> rect2.TopLeft.X:=0;<br> rect2.TopLeft.Y:=0;<br> rect2.BottomRight.X:=35;<br> rect2.BottomRight.Y:=35;<br><br> mybmp.Canvas.CopyRect(rect2,Mycanvas,rect1);<br> MyBmp.SaveToFile(FileName);<br> ReleaseDC(MyBmp.Handle,MyDC);<br>end;<br>