Admin vs Other accounts (XP)

M

Micus

Hi All,

I've created a software package. I can install it (for everyone) in the
administrator account and it works great. I then switch to another
non-administrator account and open the application but the program fails to
read any values in the registry. I'm storing the value in the
HKEY_LOCAL_MACHINE\SOFTWARE. Can all users access this registry key? If not,
what root key should I put these values in? This is happening on a Win XP
machine, although I will need to have it install on a 2000 machine as well.

For those who are c++ Win32 savvy, here is the function:

double CRegistry::ReadString(cString strName, double fDefault)
{
HKEY m_hRootKey = HKEY_LOCAL_MACHINE;
cString m_strCurrentPath = "Software\\MyApp\\Settings";
HKEY hKey;
DWORD dwType = REG_SZ;

if :):RegOpenKeyEx(m_hRootKey, LPCTSTR(m_strCurrentPath.c_str()), 0,
KEY_READ, &hKey) != ERROR_SUCCESS) return fDefault;

if :):RegQueryValueEx(hKey, LPCTSTR(strName.c_str()), NULL,
&dwType, (LPBYTE)&d, &dwSize) != ERROR_SUCCESS) d = fDefault;

return fDefault;
}

Thank you - Micus
 
N

NewScience

Most users cannot access that key unless Security Permissions are set for
Everyone to READ (at least).
If you want users to be able to copntrol their own environment, READ/WRITE
from HKEY_CURRENT_USER\Software\MyApp\Settings
 
D

Dave Patrick

Try setting up failure auditing on the local machine hive. Run regedt32.exe
then browse to HKLM, then
Edit|Permissions|Advanced|Auditing|Add|"everyone"|OK then check the "Failed"
box on Full Control, Set Value, Create Subkey, Enumerate Subkey, Delete,
Create Link

Then try again logged on as a normal user. Then check the Event log security
for errors.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect
 
M

Micus

Thanks for both of your responses. You've given me a starting point to
finding a solution. I've posted a similar question in the vc.language news
group and the response pointed to using HKEY_CURRENT_USER as well. I wish
there was a 'HKEY_CURRENT_USER\Everyone\Software' key...

Thanks again - Micus
 
M

Micus

If anyone's interested,

There were two problems and they weren't easy to find while switching
between accounts and trying to debug code. Opening a key in HKLM, as
implemented in my class using KEY_ALL_ACCESS, will fail when the app is
installed by the admin the called by a non-admin account. Solved this by
adding a GetAccessRights() method which finds the access allowed by the
user. All other registry interaction except the product key was placed in
HKCU. Everything seems to be humming along for now.

Regards,
M

Dave Patrick said:
You're welcome.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

Micus said:
Thanks for both of your responses. You've given me a starting point to
finding a solution. I've posted a similar question in the vc.language news
group and the response pointed to using HKEY_CURRENT_USER as well. I wish
there was a 'HKEY_CURRENT_USER\Everyone\Software' key...

Thanks again - Micus


fails
to
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top