从 ActiveX 写入日志文件
我正在开发一个 ActiveX,当启用 UAC 时,它可能会在 Windows7 中运行。
为了能够在客户使用 ActiveX 时遇到问题时提供支持,今天,我正在写入由我的代码打开和管理的日志文件。 问题是,当启用 UAC 时,我没有创建/修改文件的权限。
- 启用 UAC 时是否有任何位置可以写入(已尝试过 %temp% 和 %appdata% 但没有成功)。
- 是否有任何 Windows API 可用于创建/写入通过 UAC 的日志文件?
- 还有其他想法吗?
多谢。
I'm working on an ActiveX that might find itself running in Windows7 when UAC is enabled.
In order to provide the ability to support customers once they have problems working with the ActiveX, today, I'm writing to a log file opened and managed by my code.
The problem is that when UAC is enabled, I don't have permission to create/modify files.
- Is there any location that I can write to when UAC is enabled (already tried %temp% and %appdata% but none worked).
- Is there any Windows API that I can use to create/write to log files that passes the UAC?
- Any other ideas?
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
%temp%\low
windows 有时会将日志重定向到此文件夹
try
%temp%\low
windows redirects logs to this folder sometimes
您可以使用 SHGetKnownFolderPath 获取 FOLDERID_LocalAppDataLow 的路径(通常为 C:\Users\Your User\AppData\LocalLow),然后您可以写入 到。
此 API 的挑战在于它在 Windows XP 中不可用;因此,如果您使用的是 XP,则必须使用不同的 API,该 API 只会为您提供 Local Settings\Application Data 文件夹;但是,您只能使用一个或另一个 API,具体取决于您的 Windows 版本定义的设置方式。解决方法是手动加载 shell32.dll 库并搜索入口点,如果不起作用,则回退到 xp 版本。这就是我为 FireBreath (我将其用于我的 activex 浏览器插件)所做的事情。 示例代码。
有关详细信息,请参阅查找低完整性写入位置
希望有帮助
You can use SHGetKnownFolderPath to get the path for FOLDERID_LocalAppDataLow (which will usually be C:\Users\Your User\AppData\LocalLow) which you can then write to.
The challenge with this API is that it isn't available in Windows XP; so, if you're on XP, you have to use a different API which will just give you the Local Settings\Application Data folder; but, you can only use one or the other API, depending on how your windows version defines are set. The workaround is to manually load the shell32.dll library and search for the entrypoint, then fall back to the xp version if it doesn't work. That is what I did for FireBreath (which I use for my activex browser plugins). Sample code here.
For more information see Finding Low Integrity Write Locations
Hope it helps