简体   繁体   English

可配置的Windows服务-如何以及在何处存储配置

[英]Configurable Windows Service - How and where to store configuration

I created a C# application to manage data synchronization between an ERP and a CRM. 我创建了一个C#应用程序来管理ERP和CRM之间的数据同步。 This application reads a table every 500ms, and sends data via WebService to CRM. 该应用程序每500毫秒读取一张表,然后通过WebService将数据发送到CRM。 For the moment, I have two screens for my application : a first to configure connections (ERP's DB connection informations and CRM's URL and WS Token), a second with a start button to launch the loop thread. 目前,我的应用程序有两个屏幕:一个用于配置连接(ERP的DB连接信息以及CRM的URL和WS Token),第二个带有启动按钮以启动循环线程。

I know want my application to be nothing more than a windows service installer. 我知道我的应用程序只不过是Windows Service安装程序。 What I want to do is to launch my application, configure ERP and CRM connections, and then click on a 'Install' button. 我要做的是启动我的应用程序,配置ERP和CRM连接,然后单击“安装”按钮。 When this button is clicked, a service is created and makes the same work that my application makes now when i click the 'start' button. 单击此按钮后,将创建一个服务,并与我单击“开始”按钮时应用程序现在所做的工作相同。

I already read those links Converting my application in a Windows Service , Making an existing exe with gui into windows service and of course http://msdn.microsoft.com/en-us/library/d56de412%28v=vs.100%29.aspx . 我已经阅读了这些链接, 将我的应用程序转换为Windows服务将带有gui的现有exe转换为Windows服务 ,当然还有http://msdn.microsoft.com/zh-cn/library/d56de412%28v=vs.100%29 .aspx

Here is my question : 这是我的问题:

How to make a configurable windows service ? 如何制作可配置的Windows服务? I think the simplest way is to store configuration into files that utility and service would share. 我认为最简单的方法是将配置存储到实用程序和服务将共享的文件中。 Where to store those files ? 这些文件存储在哪里? The utility must be able to find these files afterwards : registry ? 该实用程序之后必须能够找到以下文件:注册表?

Thanks, 谢谢,

在.NET中,通常的做法是在此相对路径 Environment.SpecialFolder.ApplicationData存储应用程序或服务的设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM