6
我有以下C#代碼,我正在使用它捕獲遠程桌面(RDP)會話中的屏幕截圖。它會在會話處於活動狀態時正常工作,但如果我將會話最小化,則會導致無效句柄異常。捕獲最小化遠程桌面的屏幕截圖
有什麼辦法可以做到這一點,或者當會話最小化時屏幕基本上「消失」了嗎?
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);
}
程序是在遠程機器還是本地機器上運行? – siride 2010-08-09 05:06:18
它在遠程機器上運行。 – ngoozeff 2010-08-09 05:16:05