发送窗口消息,Windows服务 [英] Send windows message to a Windows Service

查看:438
本文介绍了发送窗口消息,Windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有送(模仿),就像'WM_ENDSESSION一个窗口消息窗口服务的任何工具?

Is there any tool to send (mimic) a windows message like 'WM_ENDSESSION' to a windows service?

我如何发送一个窗口消息处理使用C#?

How can I send a windows message to a process using C#?

(我只知道C#)

编辑:目的:基本上我有固定的只发生在系统关机的错误调试Windows服务

Purpose: Basically I have to debug a windows service for fixing a bug that occurs only on system shut down.

推荐答案

一般情况下,服务没有窗户(更不用说消息泵)来接收Windows消息。

Generally, services don't have windows (let alone message pumps) to receive a windows message.

如果错误确实仅发生在关断(而不是仅仅停止服务),这可能是因为一些取决于这是不被适当地处理的资源,是要离开的情况下(在这种情况下,该bug修复的可能的是正确设置服务相关性)。您是否尝试过使用远程调试工具附加到过程之前关机?

If the bug really does only happen on shutdown (as opposed to just stopping the service), it may be the case that something depends on a resource that is going away, which is not being handled gracefully (in which case, the bug fix might be to set up the service dependencies correctly). Have you tried using the remote debugging tools to attach to the process prior to shutdown?

这是值得研究,如果你能得到出现问题,而无需关闭,也许在刚停止与服务控制管理器服务(不需要编程方式做到这一点,因为这是一个调试的情况),在这种情况下,你可以在您的服务断点的onStop()(我假设C#),并看看会发生什么。

It's worth investigating if you can get the problem to occur without shutting down, perhaps when just stopping the service with the Service Control Manager (no need to do this programmatically, as this is a debugging scenario), in which case, you can breakpoint OnStop() in your service (I'm assuming C#) and watch what happens.

这篇关于发送窗口消息,Windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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