在Windows Service中接收Windows消息(WM_messages)
来源:互联网 发布:mysql like带_字符 编辑:程序博客网 时间:2024/05/01 21:27
窗口程序接收系统消息,会有相应的WndProc函数。在Service中则没有这样的函数,所以必须想办法进行消息的获取。
首先,我们建立一个类,类继承与System.Windows.Forms.Form。
#pragma once#using <System.dll>#using <System.Drawing.dll>#using <System.Windows.Forms.dll>#include <Windows.h>#include <fstream>using namespace System;using namespace System::Drawing;using namespace System::Windows::Forms;using namespace System::Security::Permissions;public ref class MessageForm : public System::Windows::Forms::Form{public:MessageForm(void){};~MessageForm(void){};protected: [SecurityPermission(SecurityAction::Demand, Flags=SecurityPermissionFlag::UnmanagedCode)] virtual void WndProc( Message% m ) override { // Listen for operating system messages. switch ( m.Msg ) { case WM_Message://Your code. break; } Form::WndProc( m ); stream.close(); }};之后,我们在服务开启之后,建立这个对象。
Application::Run( gcnew MessageForm );这样就能在服务中,进行Windows消息的处理了。
参考:http://bytes.com/topic/c-sharp/answers/610416-listening-windows-messages-windows-service
参考:http://msdn2.microsoft.com/en-us/library/system.windows.forms.message.aspx
0 0
- 在Windows Service中接收Windows消息(WM_messages)
- 如何在Qt中处理(接收/发送)MFC或Windows消息(message)
- windows接收登陆消息
- windows消息发送与接收
- 如何使对话框中接收到WM_CHAR消息(Windows编程)
- 在VS2005中调试Windows Service
- 在VS2005中调试Windows Service
- 在windows service中使用timer
- 在VS2005中调试Windows Service Windows服务
- 理解Windows消息(在Delphi中)-
- 在.net cf中处理Windows消息
- 在QT4中处理windows消息
- 在QT中处理windows消息
- 在QT中处理windows消息
- Windows(WinAPI)窗口创建后,依次接收的消息
- windows 无窗口线程消息接收
- Windows中窗口消息
- windows中自定义消息
- Map集合中使用叠代器Iterator
- 设置tomcat jdk内存
- qt for android
- Codeforces 300C Beautiful Numbers 乘法逆元
- ios 如何跳转到系统(通用)页面
- 在Windows Service中接收Windows消息(WM_messages)
- 使用无线网络别掉以轻心 网银密码随时被盗
- 一辈子好短,真的需要好好疼自己
- (精)构建高并发高可用的电商平台架构实践
- 一个弱智错误
- xml 生成,解析
- poj(1226)KMP
- Process 执行Linux命令/调用外部程序
- openfire + spark 服务