Method one, (http://topic.csdn.net/u/20070303/15/457ee919-8a0b-46c4-9dd7-8606631e2108.html)
In the EXE project to find the last line in manifest before adding the following code: to compile on it,
<ms_asmv3:trustinfo xmlns:ms_asmv3= "Urn:schemas-microsoft-com:asm.v3" >
<ms_asmv3:security xmlns:ms_asmv3= "Urn:schemas-microsoft-com:asm.v3" >
<requestedPrivileges>
< requestedExecutionLevel level= "requireadministrator" uiaccess= "false" > </ requestedexecutionlevel>
</requestedPrivileges>
</ms_asmv3:security>
</ms_ Asmv3:trustinfo>
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/vc/
However, such EXE only run administrator rights, if the general user login, you need to enter the administrator's account number and password to do. Generally is not set requireadministrator, but set it as asinvoker.
However, in some not patched XP SP2 system, the use of manifest elevated permissions may cause the system to reboot, use caution!
The VC6 is as follows: (http://blog.csdn.net/wangyong0921/archive/2008/01/21/2057662.aspx
http://www.debugman.com/read.php?tid=325)
<?xml version= "1.0" encoding= "UTF-8" standalone= "yes"?> <assembly "xmlns=
": Asm.v1 "manifestversion=" 1.0 ">
<assemblyidentity
version=" 1.0.0.0 "processorarchitecture=" X86
"
name=" test.exe.manifest "
type=" Win32 "/> <trustinfo xmlns=
" urn:schemas-microsoft-com: Asm.v3 ">
<security>
<requestedPrivileges>
<requestedexecutionlevel level=" Requireadministrator "uiaccess=" false "/>
</requestedPrivileges>
</security>
</ Trustinfo>
</assembly>
The code is added to the VC resource and can be added in the following ways:
Add a "Custom" resource, "Resource type", fill in 24, change the resource ID to 1
If you have only one executable file, you can add it in the following ways:
Mt.exe-manifest e4nmgr.exe.manifest-outputresource:e4nmgr.exe;1
Method two, (http://topic.csdn.net/u/20070303/15/457ee919-8a0b-46c4-9dd7-8606631e2108.html)
For example, I changed D:\BitSpirit\BitSpirit.exe to admin privileges.
HKEY_CURRENT_USER\Software\Microsoft\Windows Nt\currentversion\appcompatflags\layers
Add a String key value:
The name is set to "D:\BitSpirit\BitSpirit.exe"
Numeric data is set to "RunAsAdmin"