Can you access the windows registry from Adobe Air?
Asked Answered
C

8

9

(y/N)

Edit: Read-only access is fine.

Cara answered 6/8, 2008 at 16:47 Comment(2)
If you can I'd be horrified.Causality
The app is a background downloader, and I need some way of getting the users name and role, which is currently only stored in the registry. I think I could get to the registry files with read only access but obviously it would be insane to try and parse (as Jarin said). I have settled on grabbing the users name from the name of the user directory, and writing a web method on the server to get back their role. The C# was a creative idea, thanks.Cara
D
7

I haven't tried this yet, but I think I've found a workaround.

Adobe AIR cannot write to Windows Registry, but you can, however, launch a native process in AIR 2. Here's a blog post that shows how to do that: http://www.adobe.com/devnet/air/flex/quickstart/articles/interacting_with_native_process.html

Now, on Windows, you are able to modify the Windows registry with .reg files. .reg files are just plain text files that's read by regedit.exe. So in theory, you can write a .reg file to the file system, then launch regedit.exe with the .reg file passed in and...TADA! You just modified Windows registry from your AIR app!

To read value, you can use regedit's export function to write to a reg file and read from the reg file. Details to regedit's options: http://www.robvanderwoude.com/regedit.php

Here are some additional resources:
.reg file syntax: http://support.microsoft.com/kb/310516
write to file with AIR: http://www.adobe.com/devnet/air/flex/articles/exploring_file_capabilities.html

Dixiedixieland answered 23/6, 2011 at 17:33 Comment(0)
M
2

If your willing to force the user to also install another application, you could write a small C# or C++ windows service that simply opens a Socket that provides some kind of protocol for accessing the registry. Then in AIR you can use the Socket class to send messages to/from the C# service that would return results to the AIR app.

When the app loads you can try to connect to the Socket, and if the connection is rejected you could prompt the user to download/install the service.

As for direct access to the registry I am pretty sure Adobe wouldn't allow that from AIR.

Mencher answered 7/8, 2008 at 16:37 Comment(0)
D
2

If you can I'd be horrified.

Why would you be horrified? Air is a desktop platform, and having access to the OS's APIs (such as registry access) makes plenty of sense.

That being said, it isn't supported now (and as Adobe seem to be very Mac-centric, I doubt it will ever be added).

I have settled on grabbing the users name from the name of the user directory

Using File.userDirectory.name will work in most cases, but it seems like a very fragile implementation, it relies on the OS maintaining the convention of having the username as their directory. I can think of a few possible things that might break it (playing with TweakUI etc).

Duston answered 19/8, 2008 at 4:47 Comment(0)
D
2

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

Doodlebug answered 23/10, 2013 at 19:49 Comment(0)
M
1

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.

Mencher answered 7/8, 2008 at 20:2 Comment(0)
G
1

A bit late, but I got a wish from a client to read some values from the registry when the project was almost finished. If there were more of these types of wishes, I would have never choosen AIR. But I found a nice extension from FluorineFx, and by extending it, I can now read string and dword values from the registry. Windows only: http://aperture.fluorinefx.com/

Grouch answered 3/6, 2009 at 22:32 Comment(0)
W
0

You could theoretically modify the actual registry files, but I would highly discourage that idea.

Willwilla answered 7/8, 2008 at 16:39 Comment(0)
C
0

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.

Cowling answered 7/8, 2008 at 20:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.