views:

79

answers:

2

I have written a window service. and I am able to successfully install/run the service. Now I have added a timer to the service and I want to be able to adjust the interval via the registry. But I can't figure out why GetSetting("MyAppName", "MySection", "IntervalSetting") will NOT return the value in the registry!

Am I missing something? Does GetSetting() not work when called from a windows service?

A: 

does the user the service is running under have access to the registry?

Sk93
+2  A: 

From MSDN :

"GetSetting requires that a user be logged on since it operates under the HKEY_LOCAL_USER registry key, which is not active until a user logs on interactively."

What account does your service operate under? If it's LocalSystem, you effectively have no user logged on. Even if you impersonate, IIRC, that doesn't load the registry hive.

Bob Moore