Tip -How to elevate an application in VC++
Details -If your application requires administrative privileges to run correctly (for example, if it modifies the HKLM node of the registry or if it writes to protected areas of the disk, such as the Windows directory), you must modify the application as given below.
Ø Go to Project -> Properties -> Configuration Properties -> Linker ->Manifest File and do the following settings,
Ø Enable User Account control(UAC) ->yes
Ø Change UAC Execution Level -> requireAdministrator
Ø Rebuild application
· An executable that is marked as "requireAdministrator" in its manifest cannot be started from a non-elevated process using CreateProcess().
· A new process with elevated privileges can be spawned from within a native Win32 application as follows,
o “ShellExecute(hwnd, "runas", "C:\\Windows\\Notepad.exe", 0, 0, SW_SHOWNORMAL);”
· If the application is in requireAdministrator modes, failure to provide confirmation results in the program not being launched. Make sure the user belongs to the administrator group.
Posted By : Merlin S. Thadathil