에러 메시지는 다음과 같습니다.
Project Server2.exe raised exception class EOutOfResources with
messase 'Out of system resources', Process stoopped. Use Step or
Run to continue.
소스 코드는...
var
DeskTopDC: HDc;
DeskTopCanvas: TCanvas;
BitmapRect: TRect;
Bitmap: TBitmap;
jpg : TJPEGImage;
JpgStream : TMemoryStream;
Length: integer;
FileLocation: String;
begin
Bitmap := TBitmap.Create; //BMP를 저장할 bitmap 생성
BitMap.Width := Screen.Width;
BitMap.Height := Screen.Height;
BitmapRect := Rect(0, 0, Screen.Width, Screen.Height); //full screen 영역
// 전체 window의 device context(DC) 을 얻는다
DeskTopDC := GetWindowDC(GetDeskTopWindow);
DeskTopCanvas := TCanvas.Create;
DeskTopCanvas.Handle := DeskTopDC; //체 window의 canvas를 얻습니다
FileLocation := ExtractFilePath(Application.ExeName);
DeleteFile(FileLocation + Form1.ServerAddr + '.JPG');
Bitmap.Canvas.CopyRect(BitmapRect, DeskTopCanvas, BitmapRect);
jpg := TJPEGImage.Create;
with Jpg do
begin
CompressionQuality := 45;
Assign(Bitmap); // Assign the BitMap to JPEG
JpgStream := TMemoryStream.Create;
SaveToStream(JpgStream);
SaveToFile(FileLocation + Form1.ServerAddr + '.JPG');
JpgStream.Position := 0;
Length := JpgStream.Size;
end;
end;
finally
ReleaseDC(GetDeskTopWindow, DeskTopDC);
DeskTopCanvas.Free;
Bitmap.Free;
JpgStream.Free;
Jpg.Free;
end;
end;
- 위와 같은 에러가 발생합니다.
- 또다른 방법이 있을까 해서 궁금합니다...
- 많은 고수님들의 조언을 부탁드립니다.