Click here to Skip to main content
11,922,641 members (31,951 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
How can I edit or add new key to local machine while I'm working on Windows 7 with C# code?
Posted 20-Apr-13 6:24am
Edited 20-Apr-13 8:43am
Richard MacCutchan 20-Apr-13 12:21pm
You need to be an administrator to change the local machine keys.
prince.Hassan22 20-Apr-13 12:25pm
Im an adminstrator (if you mean log as computer admin when usig the application)
Richard MacCutchan 20-Apr-13 13:15pm
Then you need to set your program to use administrator privileges; you can do this by selecting the proper level in your manifest. See this article for details.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


Have a look here:
Read, write and delete from registry with C#[^][^]

Please note: you should run your application as Administrator, otherwise you can't access the registry.
prince.Hassan22 20-Apr-13 12:06pm
the Problem Is That I Cannot Access To Local_Machine Keys It Gives Me Error That I Need Permission And I Don't Know How To Get This Permission
Ian A Davidson 20-Apr-13 12:35pm
I think that's what the others have been saying - you need to run your application as local admin.
prince.Hassan22 20-Apr-13 12:41pm
That's What Im Really Doing Im Running As Admin But I Cann't Edit Local_Machine (note This Only Happens When I Use Win 7 But It's Ok In Xp) :\
ProgramFOX 20-Apr-13 12:48pm
If you're logged on as admin, but if you still get an error, then right-click on your application, and choose Run as Administrator.
prince.Hassan22 20-Apr-13 12:55pm
what if im debugging it using visual studio 2010?
ProgramFOX 21-Apr-13 7:14am
If you run Visual Studio as Administator by right clicking on the shortcut to Visual Studio and choosing Run as Administrator, Visual Studio will run your application as administrator also.
prince.Hassan22 20-Apr-13 12:57pm
Ok Fox you Were Right it Worked Only When I Right Click And Run It As Admin
But If i Want To Be Admin When I Double Click On It What Should I DO?
ProgramFOX 21-Apr-13 7:15am
CPallini 20-Apr-13 13:43pm
ProgramFOX 21-Apr-13 7:13am
Thank you!
prince.Hassan22 20-Apr-13 13:58pm
Ok Thanks Fox Every Thing Were Ok Thanks For Your Help Again
But May I ask You If You Have a facebook account If I Can Contact You?
ProgramFOX 21-Apr-13 7:13am
No, I don't have a Facebook account. I also don't need it, and to be honest, I don't want it.
prince.Hassan22 21-Apr-13 14:56pm
that's okay anyway thanks for your help
ProgramFOX 22-Apr-13 11:42am
You're welcome!

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151125.1 | Last Updated 20 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100