GDI Handles in Windows Service vs Interactive Application

喜夏-厌秋 提交于 2019-12-23 03:06:17

问题


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.


回答1:


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. :-)



来源:https://stackoverflow.com/questions/44258630/gdi-handles-in-windows-service-vs-interactive-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!