(是/否)
编辑:只读访问很好。
我还没有尝试过,但我想我找到了解决方法。
Adobe AIR 无法写入 Windows 注册表,但是您可以在 AIR 2 中启动本机进程。这里有一篇博客文章展示了如何做到这一点:http: //www.adobe.com/devnet/air/flex/quickstart /articles/interacting_with_native_process.html
现在,在 Windows 上,您可以使用 .reg 文件修改 Windows 注册表。.reg 文件只是由 regedit.exe 读取的纯文本文件。所以理论上,您可以将.reg 文件写入文件系统,然后使用传入的.reg 文件启动regedit.exe 并...TADA!您刚刚从 AIR 应用程序修改了 Windows 注册表!
要读取值,您可以使用 regedit 的导出功能写入 reg 文件并从 reg 文件中读取。regedit 选项的详细信息:http ://www.robvanderwoude.com/regedit.php
以下是一些附加资源:
.reg 文件语法: http: //support.microsoft.com/kb/310516
使用 AIR 写入文件:http: //www.adobe.com/devnet/air/flex/articles/exploring_file_capabilities。 html
如果您愿意强制用户也安装另一个应用程序,您可以编写一个小型 C# 或 C++ Windows 服务,它只需打开一个提供某种协议来访问注册表的 Socket。然后在 AIR 中,您可以使用 Socket 类向/从 C# 服务发送消息,该服务会将结果返回给 AIR 应用程序。
当应用程序加载时,您可以尝试连接到 Socket,如果连接被拒绝,您可以提示用户下载/安装服务。
至于直接访问注册表,我很确定 Adobe 不会允许从 AIR 访问。
如果可以,我会很害怕。
你为什么会害怕?Air 是一个桌面平台,访问操作系统的 API(例如注册表访问)非常有意义。
话虽如此,它现在不受支持(而且由于 Adobe 似乎非常以 Mac 为中心,我怀疑它是否会被添加)。
我已经决定从用户目录的名称中获取用户名
使用 File.userDirectory.name 在大多数情况下都可以使用,但它似乎是一个非常脆弱的实现,它依赖于操作系统维护将用户名作为其目录的约定。我可以想到一些可能会破坏它的事情(使用 TweakUI 等)。
有点晚了,但是当项目快完成时,我从客户那里得到了一个愿望,从注册表中读取一些值。如果有更多这样的愿望,我永远不会选择 AIR。但是我从 FluorineFx 中找到了一个不错的扩展,通过扩展它,我现在可以从注册表中读取字符串和 dword 值。仅限 Windows: http: //aperture.fluorinefx.com/
Are you trying to determine if the user is an administrator or not?
If so you could grad the username by with "File.userDirectory.name".
And I think to figure out if the user is an administrator you could probably try to access a file that requires administrator privileges (maybe try writing a file to Windows/System32). If the file access fails you could probably assume that the user is under a Limited account.
Here is a sample of modifying Windows Registry in Adobe Air using NativeProcess and Python. So you can Add, Delete or Read keys by only a single line of code !!
Download: Adobe Air Registry Modifier on Github
理论上您可以修改实际的注册表文件,但我强烈反对这种想法。
Be very careful if you decide to create a socket server that listens for registry commands. You are potentially creating a security hole and users' personal firewalls may get in the way in terms of usability.