C# Windows 服务中的 IE 截图问题

发布于 2024-10-06 17:53:38 字数 212 浏览 0 评论 0原文

我使用的是win 2003服务器。

我在 c# .net 中创建了 Windows 服务,它使用预定义的 URL 每 5 分钟打开 IE,获取它的屏幕截图并将其保存到数据库。这似乎是一个简单的应用程序。但我的问题是,当机器锁定(window键+l)或机器注销时,IE进程启动,但无法截屏,只能截取“黑页”。

是否有任何选项可以在登录屏幕上运行 IE?或者有解决这个问题的方法吗?

I am using win 2003 server.

I have windows service created in c# .net, it opens IE at every 5 min with predefined URL, get screen shot of it and save it to database. It seems a simple application. But my problem is, when machine is lock (window key + l) or machine is logged off, IE process is start, but cant take screen-shot, it takes "black page" only.

Is there any option to run IE at login screen? or is there any work around of this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

新人笑 2024-10-13 17:53:38

As posted in Generate WebPage Thumbmail Screenshot Image you could try using a WebBrowser control in your service and generating a screenshot from that.

朮生 2024-10-13 17:53:38

该服务需要在选中“与桌面交互”复选框的情况下运行。拍摄屏幕截图时,该窗口需要位于 Z 顺序的最上面,并且不与其他窗口重叠。正如我发现的那样,这种方法很容易出错。

The service needs to run with the "interact with desktop" check box ticked. The window needs to be upper-most in the Z-Order when the screen shot is taken and not overlapped by other windows. This approach is quite error prone...as I have found.

南风起 2024-10-13 17:53:38

要使用代码与桌面交互:

将其放在启动服务之前。

String sYourServiceName = @"MyService" //Change this to r service name
ConnectionOptions co = new ConnectionOptions(); 
co.Impersonation = ImpersonationLevel.Impersonate; 
ManagementScope mgmtScope = new System.Management.ManagementScope(@"root\CIMV2", co); 
mgmtScope.Connect(); 
ManagementObject wmiService; 
wmiService = new ManagementObject("Win32_Service.Name='" + sYourServiceName + "'"); 
ManagementBaseObject InParam = wmiService.GetMethodParameters("Change"); 
InParam["DesktopInteract"] = true; 
ManagementBaseObject OutParam = wmiService.InvokeMethod("Change", InParam, null);

或者

尝试从登录页面以系统帐户身份运行iexplore“Internet explorer”。只需从您的 Windows 服务执行 Process.Start("Iexplore.exe") 即可,但我不确定您是否可以作为系统级帐户执行 iexplore

否则,您可以尝试通过编写基本的按键抓取器或按键记录器来阻止 MENU+L 锁定,从而阻止锁定屏幕,您可以通过启用与桌面的交互来做到这一点。我发布了代码以使其更容易,或者通过转到服务并单击您的服务来手动完成。您应该会看到一个带有文本与桌面交互的复选框。

//M

To interact with desktop using code:

Put this just before you start the service.

String sYourServiceName = @"MyService" //Change this to r service name
ConnectionOptions co = new ConnectionOptions(); 
co.Impersonation = ImpersonationLevel.Impersonate; 
ManagementScope mgmtScope = new System.Management.ManagementScope(@"root\CIMV2", co); 
mgmtScope.Connect(); 
ManagementObject wmiService; 
wmiService = new ManagementObject("Win32_Service.Name='" + sYourServiceName + "'"); 
ManagementBaseObject InParam = wmiService.GetMethodParameters("Change"); 
InParam["DesktopInteract"] = true; 
ManagementBaseObject OutParam = wmiService.InvokeMethod("Change", InParam, null);

or

Try to run iexplore "Internet explorer" as a system account from the logon page. Just execute Process.Start("Iexplore.exe") from your Windows service and it should work, but I am not sure if you can execute iexplore as a system level account.

Otherwise, you can try to block the lockout screen by writing a basic key grabber or a key logger to block MENU+L lockout, you can do this by enabling interaction with desktop. I posted the code to make it easier or do it manually by going to services and clicking on your service. There you should see a checkbox with the text interact with desktop.

//M

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文