How to read registry key value in c# on windows7 64 bit

I have made one com component dll, In that one method returns Registry key value, and one is simple return string.

for e.g.
public string Hello()
            return "Hello from object";
public string IsAgent()
            return Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Test\Agent", "IsAgent", "0").ToString();

Then we have register that dll by making setup & deployment project in vs2010 (framework2.0). Then we are trying to access that method in javascript, for e.g
<html xmlns="">
<head> <title>ObjectEmbedingTest</title> </head>
<form method="POST" name="MyForm" id="MyForm">
    <object id="HelloControl" name="HelloControl" border="0"  classid="clsid:9A081BF8-6B1A-4850-B8B1-94AF1282EEC3" >

<script type ="text/javascript">
var objAgentControl = document.forms(0).HelloControl;
alert('objAgentControl=' + objAgentControl.Hello());

In this on windows7 32 bit, both methods are working fine, but when we installed it on windows7 64 bit m/c Hello() method working fine but IsAgent() is not working.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try this instead
public string IsAgent()
    RegistryKey rk = Registry.LocalMachine;
    rk = rk.CreateSubKey(@"SOFTWARE\Test\Agent");
    return rk.GetValue("IsAgent", "0");

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

registry key path will be different for Win 7 64 bit..
will be under "Wow6432Node".. your path should be like below..

procitAuthor Commented:
Yes, I have used Example 2 from this link,
And Now I can access that IsAgent method, but after loading page there is one more message "COM Surrogate has stopped working.", Is it related to this code?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.