views:

335

answers:

1

A GetPrivateProfileString() call works fine on Windows XP but fails with an Access Denied error when run on Vista.

The call is being made inside a thread spawned by a Windows service which I wrote. The Windows service itself is run using the credentials of a user account on the local machine (thought to be needed because the code requires access to HKCU).

I suspect this has something to do with the UAC or virtualization.

I would welcome any suggestions on how I can get this call to work on Vista, or on experiments I can run to help track down a solution.

Thanks

A: 

Parts of the Windows registry are locked down in Vista for security reasons.

For example if you are trying to access the HKEY_LOCAL_MACHINE this will fail for a user with out the correct privileges.

If you give the user a sufficient privilege level they will be able to access the registry but the recommended approach is to move the registry settings to the HKEY_CURRENT_USER branch of the registry, since this is not locked and is accessible by all users.

jussij
Just to clarify, my problem here is not accessing the HKLM but reading a setting out of .INI file located on network share.
Does the service's user account have access to the network?
Remy Lebeau - TeamB