Reading from registry

  • Thread starter Thread starter Totto
  • Start date Start date
T

Totto

Hi,
Is possible to read from HKEY_LOCAL_MACHINE whithout beeing loged in as
administrator or power user?
Have tried using the following code, but if loged in as User there is a
security matter.

Dim regKey As RegistryKey = Registry.LocalMachine
Dim strCheckTime As String
regKey = regKey.CreateSubKey(SubKeyOPCProgid)
strCheckTime = regKey.GetValue("CheckTime", strCheckTime)
If it's not possible to read from LocalMachine withourt beeing loged in as
Administrator or power user, where is the right place to store app settings
available to all users ?

Tnx
Totto
 
Yes, you cannot mitigate Win32 security.

OHM
Hi,
Is possible to read from HKEY_LOCAL_MACHINE whithout beeing loged in
as administrator or power user?
Have tried using the following code, but if loged in as User there is
a security matter.

Dim regKey As RegistryKey = Registry.LocalMachine
Dim strCheckTime As String
regKey = regKey.CreateSubKey(SubKeyOPCProgid)
strCheckTime = regKey.GetValue("CheckTime", strCheckTime)
If it's not possible to read from LocalMachine withourt beeing loged
in as Administrator or power user, where is the right place to store
app settings available to all users ?

Tnx
Totto
 
Totto,
Note you are attempting to WRITE to the registry, not read it!

The Administrator would need to give each user access to specific keys under
HKEY_LOCAL_MACHINE using regedit.exe to allow them to read & write there. I
believe a setup program could also set the permission (possible with a
custom Installer class). I would recommend having the setup program create
the respective keys and set the respective permissions.

Alternatively you may be able to use
System.Windows.Forms.Application.CommonAppDataPath or
System.Windows.Form.Application.CommonAppDataRegistry to store settings for
your app shared by all users.

Hope this helps
Jay
 
Tanks Jay,
Big help

Jay B. Harlow said:
Totto,
Note you are attempting to WRITE to the registry, not read it!

The Administrator would need to give each user access to specific keys under
HKEY_LOCAL_MACHINE using regedit.exe to allow them to read & write there. I
believe a setup program could also set the permission (possible with a
custom Installer class). I would recommend having the setup program create
the respective keys and set the respective permissions.

Alternatively you may be able to use
System.Windows.Forms.Application.CommonAppDataPath or
System.Windows.Form.Application.CommonAppDataRegistry to store settings for
your app shared by all users.

Hope this helps
Jay
 
It means that Win32 security will stop him doing this unless he has been
given explicit privilages to do so.

Regards
 
* "One Handed Man said:
It means that Win32 security will stop him doing this unless he has been
given explicit privilages to do so.

Thank you for the explanation!
 
Back
Top