Windows桌面服务中的屏幕截图 [英] Screen capture in windows desktop service

查看:121
本文介绍了Windows桌面服务中的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务在调试模式下运行良好,但是当我开始使用installutil时它就没有启动



我尝试了什么: < br $>


service work good in debug mode,but when i start using installutil then it is not started

What I have tried:

DateTime fileCreationDatetime = DateTime.Now;
Bitmap bitmap = new Bitmap(500, 500);
Graphics graphics = Graphics.FromImage(bitmap as Image);
string fileName = string.Empty;
fileName = string.Format("{0}.jpg", fileCreationDatetime.ToString(@"yyyyMMdd") + "_" + fileCreationDatetime.ToString(@"HHmmss"));
string filePath = "C:" + "\\Image\\" + Environment.UserName + "\\" + fileCreationDatetime.ToString(@"yyyyMMdd") + "\\";

if (!Directory.Exists(filePath))
{
    Directory.CreateDirectory(filePath);
}



graphics.CopyFromScreen(25, 25, 25, 25, bitmap.Size);
bitmap.Save(filePath + fileName, ImageFormat.Jpeg);

推荐答案

服务无法访问交互式桌面



交互式服务(Windows) [ ^ ]



如果你谷歌c#截图窗口服务你会发现其他人尝试过此类事情的各种文章和例子。



从Windows服务监控桌面窗口 [ ^ ]
Services don't have access to the interactive desktop

Interactive Services (Windows)[^]

If you google "c# take screenshot windows service" you'll find various articles and examples from other people who have tried this kind of thing.

Monitoring desktop windows from a Windows service[^]


这篇关于Windows桌面服务中的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆