I have developed an MFC application,i have used few registry conditions in the code.As the administration will be only allowed to edit the registry through any application or code.So using my application i am not able to edit the registry.To edit the registry through my MFC application i need to right click the exe and select as Run as Administrator and then run the exe.
So is there any other way so that i can give directly in the code to run the exe as a administrator.Kindly help me to solve this.
Thank you in Advance.
In your project settings for the linker is a tab for the manifest file. There is a setting called "UAC Execution Level". Normally it is set to "asInvoker". Change it to "requireAdministrator". This will do the trick for you.
Except if the main purpose of your application is to do administrative things, the recommanded way is to put operations that require administrator priviledge in another application and call that application from yours when you need to do that operation...
Also, it is recommanded to put a shield icon on the button that will executed that operation.
One of the purpose of the UAC is to discourage application creator to modify the system. It is a protection to limit what malware program can do without being noticed.
As much as possible, any changes that your application make to the file system or the registry should be in a portion that belong to that user. In some cases, you can also used public documents or application data...
Only at installation time, you should write to location that are common to all users.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)