是抓屏后画鼠标的,但内存很快耗光。我想应该是GetIconInfo的原因,因为帮助说用这个函数得到的IconInfo,需要调用的程序去删除。问题是,怎么删除这块内存呢?我找不到相应的函数
var
  CurPoint: TPoint;
  DesktopDC: HDC;
  Windowhld: HWND;
  Threadld: DWord;
  CursorX,CursorY: Integer;
  ScreenShoot1: TBitmap
begin
 ....
    Windowhld:=Windowfrompoint(CurPoint);
    Threadld:=GetWindowThreadProcessId(Windowhld,nil);
    AttachThreadInput(GetCurrentThreadId,threadld,true);
    GlobalCur := getcursor;
    AttachThreadInput(GetCurrentThreadId,threadld,false);
    GetIconInfo(GlobalCur, IconInfo);
    DrawIcon(ScreenShoot1.Canvas.handle,CursorX-IconInfo.xHotspot,CursorY-IconInfo.yHotspot,GlobalCur);
   ...
end

解决方案 »

  1.   

    你在win2000下看看你进程占用的内存就知道了,一直在涨(隔5、6秒)。在win98下更明显,程序过2到3分钟就报系统资源已满
      

  2.   

    ScreenShoot1: TBitmap;
    用过要free的
      

  3.   

    to xiaozhanger(你好) :
    ScreenShoot1.free
    这个我用了,只是省略了
      

  4.   

    上面代码忘了说了,IconInfo变量是TIconInfo类型的
      

  5.   

    附上完整代码,请大家检查
    var
      CurPoint: TPoint;
      DesktopDC: HDC;
      Windowhld: HWND;
      Threadld: DWord;
      CursorX,CursorY: Integer;
      IconInfo: TIconInfo;
      GlobalCur: HIcon;
      ScreenShoot1: TBitmap;  
    begin
      GetCursorPos(CurPoint);
      ScreenShoot1 := TBitmap.Create;
      ScreenShoot1.Width := 2*iWidth;
      ScreenShoot1.Height := 2*iHeight;
      DesktopDC := GetDC(0);
      //把整个屏幕复制到BITMAP中
      BitBlt(ScreenShoot1.Canvas.Handle, 0, 0,
             ScreenShoot1.Width, ScreenShoot1.Height, DesktopDC, CurPoint.x-iWidth,CurPoint.y-iHeight, SrcCopy);
      ReleaseDC(0, DesktopDC);
      //画光标
      if PMenuShowCursor.Checked then
      begin
        Windowhld:=Windowfrompoint(CurPoint);
        Threadld:=GetWindowThreadProcessId(Windowhld,nil);
        AttachThreadInput(GetCurrentThreadId,threadld,true);
        GlobalCur := getcursor;
        AttachThreadInput(GetCurrentThreadId,threadld,false);
        GetIconInfo(GlobalCur, IconInfo);
        DrawIcon(ScreenShoot1.Canvas.handle,CursorX-IconInfo.xHotspot,CursorY-IconInfo.yHotspot,GlobalCur);
      end;
      ImageScreen.Picture.Bitmap:=ScreenShoot1;
      ScreenShoot1.Destroy;
    end