开发者

Windows 7 sharing data between users via the registry

Where can I create/modify/delete registry keys to share data between users in the Windows 7 registry? Both of the users are non administrators and it shouldn't require admin privileges.

The application I'm working on uses the registry to write a key from userA and then userB can read/modify/delete it. Neither user has admin privileges and it won't be possible to change this.

Is there an official MSDN guide to how to use the registry in 开发者_运维百科Windows 7? Any links describing proper use of the registry would be useful.


You cannot access HKLM without elevation, so you simply cannot do what you described.

I suggest some of the following: 1. Choose other data storage, eg. database, file, etc. that all your users can access. 2. Create a windows service running as LocalSystem (that gives RW access to HKLM) and make your apps talk to the service via named pipes/COM/a socket.


The registry is for writing configuration settings, not for sharing data between users, you're really using it for the wrong purpose.

However, if you have to, the only place in the registry that would make sense even a little would be in the HKEY_LOCAL_MACHINE hive, in Software\yourapp, but I'm fairly sure that there is nowhere in there that's writeable by normal users by default.
If you are able to, you could create that key and then change the permissions for the users group so that they have full access.

This wiki article might help in seeing how the registry is best used.


On Windows 7, access to HKLM is only for apps running as admin. If you have no manifest on the app, it will virtualize, meaning write to a different per-user storage.

I think you should use a config file in a per-application location that is not per-user, like %PROGRAMDATA%, and have your setup/install (which probably does run as admin) write a single key that tells where this file is. The non admin users can then easily read and write the file while using the application.


The registry is not really the right way to do this. Can you give us some more details about what you're actually trying to do?

Are the users logged in at the same time? In this case, some kind of interprocess-communication (IPC) mechanism might work. For example: named pipes, shared memory, sockets, etc.

If not, will you have a process running at all times (i.e. a service)? This could be used as a sort of drop-box mechanism.

If you've got an installer, you could create a directory that's accessible to both users (put them in the same group, for simplicity's sake). Then you could drop message files in there.

In short: the registry is really designed for long-lived configuration settings. Short-lived communications really ought to be done some other way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜