2010-08-09 9 views
6

원격 데스크톱 (RDP) 세션에서 스크린 샷을 캡처하는 데 사용하는 다음 C# 코드가 있습니다. 세션이 활성 상태 일 때 제대로 작동하지만 세션을 최소화하면 잘못된 핸들 예외로 실패합니다.최소화 된 원격 데스크톱의 스크린 샷 캡처

이 작업을 수행 할 수있는 방법이 있습니까, 아니면 세션이 최소화되었을 때 화면이 근본적으로 "없어 졌습니까?

string filename = @"C:\Snap.png"; 
Size bitmapSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); 
using (Bitmap bitmap = new Bitmap(bitmapSize.Width, bitmapSize.Height, PixelFormat.Format24bppRgb)) 
using (Graphics graphics = Graphics.FromImage(bitmap)) 
{ 
    graphics.CopyFromScreen(// Exception thrown here 
     new Point(0, 0), 
     new Point(0, 0), 
     bitmapSize); 
    bitmap.Save(filename, ImageFormat.Png); 
} 
+0

프로그램이 원격 시스템이나 로컬 시스템에서 실행되고 있습니까? – siride

+0

원격 컴퓨터에서 실행 중입니다. – ngoozeff

답변

4

임시로 창을 복원하고 캡처하고 다시 최소화해야합니다. This link shows how to do it silently

+0

클라이언트에서 스크린 샷을 찍으면 작동합니다. 나는 원격 세션 내에서 작동하는 것을 선호 할 것이지만, 그 밖의 아무것도 나오지 않으면 나는 갈 것이다. – ngoozeff