1. First, create a file named XXX.exe.manifest, and copy the following to the file
<?xml version="1.0"encoding="UTF-8"Standalone="Yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1"manifestversion="1.0"> <assemblyidentity version="1.0.0.0"processorarchitecture="x86"name="J2534ToolDemo.exe.manifest" //different projects, only need to modify the project name hereType="Win32"/> <trustinfo xmlns="Urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedexecutionlevel level="requireadministrator"uiaccess="false"/> </requestedPrivileges> </security> </trustInfo> </assembly>
2. Then import this XXX.exe.manifest into the resource view
Directly select "Import (M) ..."
Find the XXX.exe.manifest file to import in the project
Here, add the resource type of the import file, set to "Rt_manifest", and then "OK"
In the end, it shows up in the resource view.
3. First configure the project properties
Project-"XXX Properties-" Configuration Properties-"linker-" manifest file
Recompile, and then choose Run vs with Administrator privileges, the system will turn off the existing vs editor to open again with administrator privileges, and then the manually compiled application is automatically run with Administrator privileges ...
VS set the compiled program to run as Administrator