【发布时间】:2009-10-20 16:18:45
【问题描述】:
我有一个在客户端机器上运行的 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;
可能是什么原因,我该如何解决?
【问题讨论】:
标签: c# windows-services screenshot