从 Windows 服务获取 %appdata% [C++]
正如主题中所述 - 有没有办法获取当前登录的用户 appdata 环境变量?
在应用程序中,使用 SHGetFolderPath() 或简单的 getenv("appdata") 执行此操作没有问题,但在服务中这些方法不起作用。它以“SYSTEM”帐户运行。
我认为这应该是使用 WMI 获取 %appdata% 的一种方法,但我对此不确定。
%userprofile% 是我在获取 %appdata% 时处理它的第二个兴趣点。
As in the topic - is there any way to get currently logged user appdata environment variable?
In an application there is no problem to do that with SHGetFolderPath() or simply getenv("appdata") but in service these methods doesn't work. It runs as "SYSTEM" account.
I think that should be a way to obtain %appdata% using WMI but I'm not sure about that.
%userprofile% is the second point of interest by I handle it when I will get %appdata%.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从服务的角度来看,不存在“当前登录的”用户这样的东西。可能有零个、一个或多个。此外,如果您的服务需要它,它通常表明存在设计错误。您想要解决的真正问题是什么?
From a service viewpoint, there's no such thing as "the" currently logged-on user. There might be zero, one or more. Furthermore, it generally indicates a design error if your service needs it. What is the real problem you're trying to solve?