Vista UAC Programming

 

I will introduce a solution Vista UAC programming here.

User Account Control (UAC) is a new security component in Windows Vista. UAC enables users to perform common tasks as non-administrators, called standard users in Windows Vista, and as administrators without having to switch users, log off, or use Run As. For the detailed information, please refer to http://technet2.microsoft.com/WindowsVista/en/library/0d75f774-8514-4c9e-ac08-4c21f5c6c2d91033.mspx?mfr=true.

If your program need to add UAC support, you will have to add a manifest file to your resource files, or build a manifest file the same to your executable file. For example, “Product1.exe.manifest” in the same directory for an executable file” Product1.exe”.  The following illustrate  it,

 1<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 2<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
 3<assemblyIdentity
 4version="1.0.0.0"
 5processorArchitecture="X86"
 6name="Product1.exe.manifest"
 7type="win32"
 8/>
 9<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
10<security>
11<requestedPrivileges>
12<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
13</requestedPrivileges>
14</security>
15</trustInfo>
16</assembly> 

The attached file gives a sample of this file. .

For BCB projects, it can add this file as a resource. Create a file with extensive name “.rc”, for example, “Vista.rc”. and fill the file with

1 24 "Project1.exe.manifest"

Run "brcc32.exe vista.rc“ to build the resource file to a Res file, and then add this Res file to your project to compile.

posted on 2008-03-26 17:11  davidwang  阅读(490)  评论(0编辑  收藏  举报

导航