The UAC mechanism provided by Vista is one of the new features of Vista. Its main purpose is to prevent malicious modifications to the operating system itself. If you want to modify the system settings of Vista, you must pass UAC verification. This method greatly provides system security. Regarding the advantages and disadvantages of UAC, the opinions on the network are mixed. We will not discuss them here. The Influence of UAC on Delphi mainly lies in the following points: 1. Due to the UAC mechanism, Delphi may silently fail to operate the system, and the same program may run normally under 2000/X. For example, registry modification... 2. To avoid this situation, the Delphi program must support Vista UAC annotation, that is, the shield icon is displayed under the UAC Program icon. In this way, you can remind users when they need higher system permissions. To enable the program to display the UAC flag, Vista now determines whether to display the "UAC shield" by reading the manifest resource in the resource of the program ". To support Vista, the Delphi program must embed manifest information in the resource. 1. edit a file with the following content:
<? XML version = "1.0" encoding = "UTF-8" standalone = "yes"?> <Assembly xmlns = "urn: Schemas-Microsoft-com: ASM. V1" manifestversion = "1.0"> <Trustinfo xmlns = "urn: Schemas-Microsoft-com: ASM. V3"> <Security> <Requestedprivileges> <Requestedexecutionlevel level = "requireadministrator"/> </Requestedprivileges> </Security> </Trustinfo> </Assembly> |
Keep it as UAC. manifest. The file is random here. Pay special attention to the red "requireadministrator", which indicates that the program must run properly as administrator. 2. Edit an RC file named UAC. RC.
Where: 1-resource ID 24-the resource type is rtmainifest UAC. manifest-previous file name 3. Use brcc32 to compile the RC file as the res file. Brcc32 UAC. RC-fouac. Res // Note: brcc32.exe is in the delphix \ bin directory. 4. Add in the program {$ R uac. Res} Compile UAC. Res into the EXE file during Delphi compilation. 5. Put the file in Vista and run it. The UAC shield icon is displayed under the program icon. |