Changing Registry programaticly

Hi to all!
I'm trying to change "GlobalUserOffline" in registry from my application.
this is the code I'm using:


HKEY hkey;
DWORD m_tmpWord;
m_tmpWord=0x00000000;
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", 0, KEY_ALL_ACCESS, &hkey);
RegSetValueEx(hkey,"GlobalUserOffline",0,REG_DWORD,(LPBYTE)&m_tmpWord,sizeof(DWORD));
RegCloseKey(hkey);

When I start application everything looks OK, but there isn't any change in registry.
What I'm doing wrong.

OS is Windows 2000, IE 6.

Greetings.
KukiPeiAsked:
Who is Participating?
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.

Jaime OlivaresSoftware ArchitectCommented:
Try to use RegOpenKeyEx with KEY_READ security attribute.
0

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
KukiPeiAuthor Commented:
It doesn't work.
0
KukiPeiAuthor Commented:
I solved the problem.

Insted of HKEY_LOCAL_MACHINE I use HKEY_CURRENT_USER and everything work fine.

Becouse you are the only one who respond to my question I'l give you all points.
Thank you.
Greetings.
0
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
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.