TService不会处理消息 [英] TService won’t process messages

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

问题描述

我已经创建了一个使用Windows消息系统的Windows服务。当我从调试器测试应用程序时,消息很好地进行,但是当我安装它时,我的messag ... 14分钟前问了

I have created a windows service that uses Windows Messaging System. When I test the app from the debugger the Messages go through nicely but when I install it my messag … asked 14 mins ago

vladimir
1tuga

vladimir 1tuga

推荐答案

服务通常不会收到窗口消息。他们根本不一定有窗口把手。即使这样做,他们也可以在单独的桌面上运行。程序无法将消息从一个桌面发送到另一个桌面,因此服务只能从另一个服务或从服务启动的程序接收邮件。

Services don't generally receive window messages. They don't necessarily have window handles at all. Even if they do, they run in a separate desktop. Programs cannot send messages from one desktop to another, so a service can only receive messages from another service, or from a program started by a service.

在Windows Vista之前,您可以配置您的服务与桌面交互。这使得服务与登录的用户在同一台​​桌面上运行,因此作为该用户运行的程序可以将消息发送到服务的窗口。 Windows Vista隔离服务;他们不能与任何用户的桌面交互。

Before Windows Vista, you could have configured your service to interact with the desktop. That makes the service run on the same desktop as a logged-in user, so a program running as that user could send messages to your service's windows. Windows Vista isolates services, though; they can't interact with any user's desktop anymore.

还有许多其他方式与服务进行通信。它们包括命名管道,邮槽,内存映射文件,信号量,事件和套接字。

There are many other ways to communicate with services. They include named pipes, mailslots, memory-mapped files, semaphores, events, and sockets.

例如,使用套接字,您的服务可以在打开的端口上侦听,并且需要与其通信的程序可以连接到该端口。这可能打开了远程管理的门,但您也可以限制服务仅监听本地连接。

With a socket, for instance, your service could listen on an open port, and programs that need to communicate with it could connect to that port. This could open the door to remote administration, but you can also restrict the service to listen only for local connections.

上述所有内容都是试图告诉你,你是采取错误的做法。但还有一个问题在于手头。您的程序在调试器中的一种方式和外部的其他方式。首先如何调试服务,如果没有安装?您的服务运行的用户帐户是什么?你的调试器?您尝试过哪些调试技术不涉及调试器(例如, writeln 到日志文件以跟踪程序的操作)?

All the above is trying to tell you that you're taking the wrong approach. But there's also the matter of the problem at hand. Your program behaves one way in the debugger and another way outside it. How are you debugging the service in the first place, if it's not installed? What user account is your service running as? Your debugger? What debugging techniques have you tried that don't involve the debugger (e.g. writeln to a log file to track your program's actions)?

这篇关于TService不会处理消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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