在Windows服务中存储配置数据的推荐方法是什么?

huangapple go评论74阅读模式
英文:

What's the recommended way to store configuration data in a Windows service?

问题

所以,我用Go编写了一个Windows服务,使用了这个API。

一切都运行良好,但我想知道在服务中存储配置数据的最佳方法是什么。

通常,我使用SHGetKnownFolderPath来获取AppData目录,并在其中创建我的应用程序目录。

然而,在服务中,这会给我一个路径在C:/Windows/system32/config/userprofile下,从技术上讲这是可以的,因为我可以在那里做我需要的事情,但我想知道是否有更好的方法来存储配置。

在这种情况下,使用注册表是否更好?或者在Windows上是否有其他用途的东西?

在这种情况下,Windows系统管理员对服务有什么期望?

谢谢。

英文:

So, I have written a Windows service in Go using this API.

Everything is working well, but I am wondering what's the best way to store configuration data in a service.

Usually, I use SHGetKnownFolderPath to get to the AppData directory and create my app directory in there.

However, in a service this gives me a path in C:/Windows/system32/config/userprofile, which is fine technically since I can do what I need in there, but I'm left wondering if maybe there's a preferred way to store configuration.

Is it better to use the registry for this ? Or is there something else on Windows for this purpose ?

What do Windows sysadmins expect from a service in this case ?

Thanks.

答案1

得分: 2

你最好将配置数据存储在注册表中。这是一个典型的Windows管理员对一个良好行为的服务的期望。Windows不是Unix。:-)

你可以使用这个包与注册表进行交互。

英文:

You are almost always better off storing your configuration data in Registry. That is what a typical Windows admin would expect of a well behaved service. Windows ain't Unix. 在Windows服务中存储配置数据的推荐方法是什么?

You can use this package to interact with the registry.

huangapple
  • 本文由 发表于 2015年10月26日 23:49:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/33350024.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定