Click here to Skip to main content
14,974,585 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I was trying to read a simple registry keyvalue using the below code:
Dim aa As Object
aa = Registry.GetValue("HKEY_CURRENT_USER\\Software\\Avira\\AntiVir Desktop", "LastCommandLine", Nothing)

aa variable value is always Nothing.

What am I doing wrong here?
Please advise.

Then I tried the same in C# code and its working fine.
The code is As below:
object  aa = Registry.GetValue("HKEY_CURRENT_USER\\Software\\Avira\\AntiVir Desktop","LastCommandLine",null);
Updated 9-Oct-12 9:34am

1 solution

Dim aa As Object
       aa = Registry.GetValue("HKEY_CURRENT_USER\Software\Avira\AntiVir Desktop", "LastCommandLine", Nothing)

Can you see why? The key value you really need is "HKEY_CURRENT_USER\Software\Avira\AntiVir Desktop"; and the double '\\' simply means escaped '\', by C# syntax, not VB.NET. To make C# code similar, use verbose modifier '@':
object aa = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Avira\AntiVir Desktop","LastCommandLine", null);

Better now? :-)

arun_pk 9-Oct-12 13:35pm
not better .. just the best :) my 5
You accepted it -- thank you, but probably forgot to vote :-)
[no name] 9-Oct-12 13:45pm
Here you Go!
You, too? :-)
Thank you, Rais.
arun_pk 9-Oct-12 13:56pm
done thank you Sergey
Pleasure to work with an inquirer who can actually use the help and do the job right. Unfortunately, most of our inquirers these days are underqualified for such things.

You are very welcome.
Good luck, call again.
arun_pk 9-Oct-12 14:42pm
what is an inquirer?
You, in this case. :-) This is one way to call a person who asks a question. What I meant to say that it was my pleasure to work with you, who immediately got the solution and was able to use it.

Also, CodeProject people often call them "OP" -- Original Publisher...
arun_pk 9-Oct-12 14:51pm
ok ..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900