How to access Application.UserAppDataRegistry settings from a Windows service

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

I have a client app that writes a value to the registry (camera device ID).
I have used Application.CommonAppDataRegistry to write the value in my test
app.

How do I retrieve this data from a Windows service? Is the application
object accessible at all?

Cheers
 
Hi Bob,

The MSDN said,
If the key does not exist, it is created in the following format:
LocalMachine\Software\ CompanyName\ ProductName\ ProductVersion
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwindowsformsapplicationclasscommonappdataregistrytopic.asp

Provided the client app is WindowsApplication18, the info will be stored in
the key path below.
HKLM\SOFTWARE\WindowsApplication18\WindowsApplication18\1.0.1392.32335
You may try to use the registrykey class to restrieve the data from the key
above.
e.g.
[Client app]
Application.CommonAppDataRegistry.SetValue("hello","world")

[Windows Service]
Dim str As String
Dim lm As RegistryKey
lm = Registry.LocalMachine
Dim rkey As RegistryKey =
lm.OpenSubKey("SOFTWARE\WindowsApplication18\WindowsApplication18\1.0.1392.3
2335")
str = CType(rkey.GetValue("hello"), String)
rkey.Close()

If you have any question on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Bob,

Did my suggestion works for you?
If you have any question on this issue please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top