英文:
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.
You can use this package to interact with the registry.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论