Windows Service与交互式应用程序中的GDI处理 [英] GDI Handles in Windows Service vs Interactive Application

查看:125
本文介绍了Windows Service与交互式应用程序中的GDI处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Winforms应用程序中使用的代码. Windows Service(作为Windows Service运行的exe)中也使用了相同的代码.该代码抓住了ICON的句柄.但是我发现的是,在Task Mangaer(和GDI视图)中,当我运行Winforms应用程序时,该应用程序会显示GDI计数.但是,当我通过Windows Service运行代码时,任务管理器中的服务实例未显示GDI的任何计数.那么,这是否意味着Windows Service永远无法持有GDI句柄?如果是这样,代码是如何工作的,这就是在Windows Service中实际在句柄上运行的代码的工作方式.

I have a code that is used in an Winforms application. The same code is also used in a Windows Service (exe running as Windows Service). The code grabs the handles to ICONs. But what I found is that, in Task Mangaer (and GDI View), when I ran the Winforms Application the app shows the GDI count. But when I ran the code via Windows Service, the service instance in Task Manager isn't showing any count for GDI. So, does this mean that Windows Service can never hold a GDI handle? If so, how does the code work, that is how is the code that runs on the handle actually working in Windows Service.

推荐答案

服务实际上能够以与普通应用程序完全相同的方式创建和使用GDI句柄,只是用户看不到显示表面.

Services are in fact able to create and use GDI handles in exactly the same way as an ordinary application, except that the display surfaces are not visible to the user.

但是,任务管理器只能查询此信息以

However, Task Manager is only able to query this information for processes that are in the same session that it is running in, and services always run in a separate session.

因此,基本上,这只是一个虚假的警报. :-)

So, basically, just a false alarm. :-)

这篇关于Windows Service与交互式应用程序中的GDI处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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