如何在对话框中运行带窗口服务的程序? [英] How do I run a program with window services in the dialog?

查看:62
本文介绍了如何在对话框中运行带窗口服务的程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的VC ++代码中,



我想在点击A.exe对话框中的开始按钮时将B.exe背景作为窗口服务运行?







A.exe如何向B.exe发送消息或发送数据并从中接收B.exe?



谁有简单的例子?



提前谢谢。



我尝试过:



此计划浪费了2天。

In my VC++ code,

I want to run the B.exe background as window service when clicking "start" button in the dialog of A.exe?

and

How can A.exe send message or send data to B.exe and receive from B.exe?

Who have any simple example?

Thank you in advance.

What I have tried:

More 2 days wasted for this program.

推荐答案

首先,您必须安装该服务。以编程方式启动服务使用 OpenService功能(Windows) [ ^ ]和 StartService功能( Windows) [ ^ ]。请注意,这要求程序以足够的权限执行。



或者使用Windows PowerShell(从程序中执行shell命令)。请参阅 Start-Service [ ^ ]。



进程间数据交换的一般术语是IPC(进程间通信(Windows) [ ^ ])。您应该阅读可用的方法并选择符合您要求的方法。 CodeProject文章 Windows IPC [ ^ ]详细解释了一些方法及其优缺点,并提供了示例代码。
At first you have to install the service. To start a service programmatically use the OpenService function (Windows)[^] and the StartService function (Windows)[^]. Note that this requires that the program is executed with sufficient priviliges.

Alternatively use the Windows PowerShell (execute shell commands from your program). See Start-Service[^].

The general term for data interchange between processes is IPC (Interprocess Communications (Windows)[^]). You should read about the available methods and choose one that matches your requirements. The CodeProject article Windows IPC[^] explains some methods in detail with their advantages and disadvantages and provides example code.


首先,B.exe必须符合服务规则 - 不是每个可执行文件都可以作为服务运行!!!

我还建议让B.exe自助安装服务,这样你就可以了从单个命令行启动和停止...

有这些服务的示例:

Windows服务可以自己安装 [ ^ ]

Windows服务托管多个WCF服务 [ ^ ]
First of all B.exe must fit the rules of a service - not every executable can run as service!!!
I would also advise to make B.exe a self installing service, so you can start and stop it from a single command line...
There are samples for such services:
Windows Services Can Install Themselves[^]
Windows Service to Host Multiple WCF Services[^]


这篇关于如何在对话框中运行带窗口服务的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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