无法捕获屏幕
问题描述:
我在客户机上运行了Windows服务。我需要捕获客户端的屏幕并通过远程将其发送到服务器。当我运行exe文件时,它可以捕获屏幕并将其发送给服务器。但是,当我将其作为服务运行时,它会记录以下错误:无法捕获屏幕
“句柄无效。”
该服务的“与桌面交互”复选框被选中。我用于截图的代码是:
Image bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot);
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
return bmpScreenshot;
可能是什么原因以及如何解决此问题?
你现在正式成为我们公司当天的英雄。 – 2009-10-20 16:34:13
我不确定这是如何回答这个问题的。决议是什么? – 2009-12-30 05:36:08
@Michael我为这个问题增加了一个可能的解决方案。 – 2009-12-30 06:29:57