如何创建窗口服务的多个实例? [英] How to create multiple instance of window service?

查看:101
本文介绍了如何创建窗口服务的多个实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想不用再安装窗口服务运行在服务器上安装一个窗口服务的多个实例。

I want to run multiple instances of a window service installed on a server without installing window service again.

这怎么可能?

推荐答案

一个服务安装实际上只是增加一个名,可执行文件,和元数据的几个其他位之间的映射。服务,一旦安装,要么运行(一次),或事实并非如此。有多个实例中运行的作为服务的,他们将不得不使用不同的名字,这基本上意味着在安装它多次注册。这确实的没有的,然而,意味着你需要可执行文件的多个不同的副本。

A service "installation" is really just adding a mapping between a name, an executable, and a few other bits of metadata. A service, once installed, is either running (once), or it isn't. To have multiple instances running as services, they would have to be registered with different names, which basically means installing it multiple times. That does not, however, mean that you need multiple different copies of the executable.

我做的是继承安装,这样它创建一个的ServiceInstaller ServiceProcessInstaller ,并给出了一个服务名称(在运行时,通过自定义安装程序)的的ServiceInstaller 实例,然后使用 ManagedInstallerClass 在运行时 - 基本上使得能够安装和卸载本身作为一个服务(许多次,只要你喜欢),使用命令行的独立的EXE参数指定的名称。

The way I do it is to subclass Installer such that it creates a ServiceInstaller and ServiceProcessInstaller, and gives a ServiceName (at runtime, via the custom installer) to the ServiceInstaller instance, then use ManagedInstallerClass at runtime - basically making a standalone exe capable of installing and uninstalling itself as a service (as many times as you like), using command-line parameters to specify the name.

这篇关于如何创建窗口服务的多个实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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