1. Static link mode for Project Properties
2. Add the following to the resource file:
/////////////////////////////////////////////////////////////////////////////
//
// 24
//
1 24 "res\\win7admin.manifest"
The content of the win7admin. manifest file is:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*' />
</dependentAssembly>
</dependency>
<assemblyIdentity
processorArchitecture="x86"
version="5.1.0.0"
type="win32"
name="MyApplication"
/>
<description> My Application </description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="x86"
/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
3. Add the file "res \ win7admin. manifest" to the project"
If you want to call other programs, try ShellExecuteEx runas.
Reference: http://www.codeproject.com/KB/vista-security/UAC__The_Definitive_Guide.aspx