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