很急:怎样抓取屏幕?(在线等)

解决方案 »

  1.   

    // 带鼠标抓图
    function CaptureScreen:TBitmap;
    var
     DC : HDC;
     ABitmap  : TBitmap;
     CI: TCursorInfo;
    begin
     DC := GetDC(GetDesktopWindow);
     ABitmap := TBitmap.Create;
     try
        ABitmap.Width := GetDeviceCaps(DC,HORZRES);
        ABitmap.Height := GetDeviceCaps(DC,VERTRES);
        BitBlt(ABitmap.Canvas.Handle,
               0,
               0,
               ABitmap.Width,
               ABitmap.Height,
               DC,
               0,
               0,
               SRCCOPY);
        ZeroMemory(@CI,SizeOf(CI));
        CI.cbSize := SizeOf(CI);
        if GetCursorInfo(CI) then
        DrawIconEx(ABitmap.Canvas.Handle,
                   CI.ptScreenPos.X,
                   CI.ptScreenPos.Y,
                   CI.hCursor,
                   16,
                   16,
                   0,
                   0,
                   DI_DEFAULTSIZE OR DI_NORMAL); finally
        ReleaseDC(GetDesktopWindow,DC);
     end;
     Result := ABitmap;
    end;