Read from Registry on Vista

V

vovan

I'm using this approach to read from registry.
Dim f As New RegistryPermission(RegistryPermissionAccess.AllAccess, _
"HKEY_LOCAL_MACHINE\SOFTWARE\SRS
Enterprises\Coordinator\Settings")
'Vlad 02/12/2007
Dim f2 As New
RegistryPermission(RegistryPermissionAccess.AllAccess, _
"HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE\SRS
Enterprises\Coordinator\Settings")

Dim pRegKey As RegistryKey = Registry.LocalMachine
pRegKey.OpenSubKey("SOFTWARE\\SRS
Enterprises\\Coordinator\\Settings")
Dim val As Object = pRegKey.GetValue("CSSLQN")

It works on Windows XP, on Windows Server 2003. It doesn't work on Vista
Business. pRegKey.GetValue("CSSLQN") returns null. The key with value
exists.

What should I add to my code to get the value from a registry?
Thank you

Vovan
 
N

Newbie Coder

After the registry permission declaration you don't use demand or assert.
So, you declare it but never use it

Dim f As New RegistryPermission(RegistryPermissionAccess.AllAccess,
"HKEY_LOCAL_MACHINE\SOFTWARE\SRS Enterprises\Coordinator\Settings")

f.Demand() ' Personally I use ASSERT because at the end you can use
f.RevertAssert(), but you cannot do that with Demand()

Please try & post back
 
S

Steve Cochran

First of all, why do you set the permissions to all access when you are just
reading? Second, why are you using \\ instead of \ ?

maybe you need to proofread your doce

steve
 
V

vovan

I found the sample of the code a couple of years ago. I replaced its values
with my values and it worked right away.
Since that I never had any problem with that code before Vista.
I use it in Windows Service project.
I tested it in Windows Form project. It works on Vista.
So the same code does work in Windows Form project on Vista, in any project
before Vista and doesn't work in Windows Service project on Vista.
What's the difference?

Vovan
 
S

Steve Cochran

I guess they got more specific in what they would allow and not allow or
what was conventional or not. I don't know, but the error is probably due
to the double slashes.

steve
 
D

dbahooker

sorry dude

vb 2002, 2003 and 2005 don't work on vista

welcome to visual fred, bitch you should have known better than to
trust MS
 
L

Larry Linson

no .NET does .NOT run on Vista

Vb6 works perfectly though

ROFL

man.. where do they get their strategy.. out of a cracker jack box?
 

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