跳到主要內容

UAC VC2005

The assembly identity
The name
The type
The description
The attributes in the requestedExecutionLevel

Application Manifest Schema:

==========================================================
Windows Vista only

<?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="IsUserAdmin"
     type="win32"/> 
  <description>Description of your application</description> 
  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"/>
        </requestedPrivileges>
       </security>
  </trustInfo>
</assembly>
==========================================================

==========================================================
Windows XP and Windows Vista

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
   <ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft- 
     com:asm.v2">
      <ms_asmv2:security>
         <ms_asmv2:requestedPrivileges>
            <ms_asmv2:requestedExecutionLevel level="asInvoker">
            </ms_asmv2:requestedExecutionLevel>
         </ms_asmv2:requestedPrivileges>
      </ms_asmv2:security>
   </ms_asmv2:trustInfo>
</assembly>
==========================================================

in the rc file to append below:

#define MANIFEST_RESOURCE_ID 1
MANIFEST_RESOURCE_ID RT_MANIFEST "IsUserAdmin.exe.manifest"


in the project:

1. Open your project in Microsoft Visual Studio 2005.
2. Under Project, select Properties.
3. In Properties, select Manifest Tool, and then select Input and Output.
4. Add in the name of your application manifest file under Additional manifest files.
5. Rebuild your application.


To insert a default manifest file into the target executable with mt.exe:

Use mt.exe to insert the manifest.  The command would be: mt.exe –manifest temp.manifest –outputresource:YourApp.exe;#1
or
Adding the Application Manifest as a Step in Visual Studio Post-Build.

PS.上面的做法是參考一些網站整理出來的,但是本身並沒有真的這樣做,後來改用,直接建立一個 manifest 的檔案,然後在 VC 2005 把這個檔案加入專案裡,重新編譯即可,可使用 Resource Haker 之類的軟體來看編譯後的執行檔是否真的有把 manifest 給嵌入進去。

留言