Vista 中全局应用程序数据放在哪里?

发布于 2024-07-16 19:15:11 字数 267 浏览 3 评论 0原文

我应该在 Windows (Vista) 系统中的哪个位置放置每个人(即计算机的每个用户)都应该可读和可写的数据? Vista的C:\Users\xxx\AppData\something、C:\Program Files和C:\ProgramData目录以及UAC的概念有点混乱。

此外,有没有现成的解决方案可以用Java确定这些位置? 我认为它需要与本机库进行一些交互,因为 System.getProperties 只有 user.home 和 user.dir,两者都不是全局可写的。

Where in a Windows (Vista) system should I place data that ought to be readable and writable by everyone, i.e. every user of the computer? Vista's concepts of C:\Users\xxx\AppData\something, C:\Program Files and C:\ProgramData directories and UAC are a bit confusing.

Furthermore, is there any ready solution to determine those locations with Java? I suppose that it requires some interaction with native libraries, since System.getProperties has just user.home and user.dir, neither of which is globally writable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

2024-07-23 19:15:11

在 vista 中,c:\ProgramData 是这个位置,它取代了 XP 中原来的 C:\Documents and Settings\AllUsers\AppData。

我不确定在 java 中执行此操作的具体细节。但是,如果您能掌握该路径,则 ALLUSERSPROFILE 环境变量会为您提供路径。 您应该始终使用此选项,而不是对路径进行硬编码,因为文件夹名称会在不同国际化版本的操作系统上发生变化。

In vista c:\ProgramData is the place, this replaces what used to be C:\Documents and Settings\AllUsers\AppData in XP.

I'm not sure about the specifics of doing this in java.. but, the ALLUSERSPROFILE environment variable gives you the path if you can get hold of that. You should always use this instead of hard coding the path, because the folder name changes on different internationalized versions of the OS.

旧人哭 2024-07-23 19:15:11

如果您需要允许没有管理员权限的用户修改全局设置,那么正确的方法是为应用程序创建一个安装程序,并在安装过程中设置“通用应用程序数据”文件夹的权限,以便允许用户区域写信给它。

请参阅这篇文章:在哪里放置常见的可写应用程序文件?

If you need to allow users that do not have administrator privileges to modify the global settings then the proper approach is to create an installer for the application and during the install set the permissions on the "Common Application Data" folder such that users area allowed to write to it.

See this post: Where to put common writable application files?

噩梦成真你也成魔 2024-07-23 19:15:11

除非数据非常大,否则您可能需要查看 首选项 API; 特别是 Preferences.systemNodeForPackage。 这为您提供了一个独立于平台、系统范围、与后端无关的存储设施(如果这就是您所追求的)。

Unless the data is really large, you might want to take a look at the Preferences API; in particular Preferences.systemNodeForPackage. This gives you a platform-independent, system-wide, backend-agnostic storage facility, if that's what you're after.

青芜 2024-07-23 19:15:11

另外,有没有准备好的
确定这些位置的解决方案
用Java?

您可以检查适当的环境变量,例如%PROGRAMDATA%,%PROGRAMFILES%等。

Furthermore, is there any ready
solution to determine those locations
with Java?

You can check approrpirate environment variables, for instance %PROGRAMDATA%, %PROGRAMFILES% and others.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文