2015-10-26 15:49
浏览 37


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 ?


图片转代码服务由CSDN问答提供 功能建议


一切正常,但是我想知道什么是最好的方法 将配置数据存储在服务中。

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

但是,在此服务中 在C:/ Windows / system32 / config / userprofile中为我提供了一条路径,从技术上讲这是很好的,因为我可以在那里进行所需的操作,但是我想知道是否存在一种存储配置的首选方法。

为此使用注册表更好吗? 或者Windows上还有其他用途吗?


谢谢。 >

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongya1875
    dongya1875 2015-10-26 15:57

    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.

    点赞 评论