zoukankan      html  css  js  c++  java
  • 在C++Builder2010中支持UAC机制

    1. 将下面内容保存为文件UAC.XML,注意编码方式为 UTF-8 

    --------------------------------------------------以下是UAC.XML内容--------------------------------------------------

    <?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" uiAccess="false"> 

            </requestedExecutionLevel>    

          </requestedPrivileges>    

        </security>    

      </trustInfo>    

      <dependency>    

        <dependentAssembly>    

          <assemblyIdentity type="win32"    

                 name="Microsoft.Windows.Common-Controls"    

                 version="6.0.0.0"    

                 processorArchitecture="x86"    

                 publicKeyToken="6595b64144ccf1df"    

                 language="*"> 

          </assemblyIdentity>    

        </dependentAssembly>    

      </dependency>    

    </assembly>

    --------------------------------------------------以上是UAC.XML内容--------------------------------------------------


    2. 将下面内容保存为文件uac.rc 

    1 24 "UAC.XML"


    其中:  

      1-代表资源编号  

      24-资源类型为RTMAINIFEST   

      UAC.XML前面的文件名称 


    uac.rc 和UAC.XML都放在工程文件夹下面  


    3. 将uac.rc加入到C++Builder2010项目,编译链接。




    不成功的可以试试国外的方法:

    http://tapanpandey.com/2009/08/30/adding-uac-elevation-manifest-in-visual-c-8-0-visual-studio-2005-c-or-c-project/


    To add application manifest to a C or C++ application in Visual Studio 2005 so that Vista automatically display the elevation dialog while the application launch do the following steps:

    1. Open the notepad and write down following statement 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=”Microsoft.Windows.EnableUAC”
      type=”win32″/>
      <trustInfo xmlns=”urn:schemas-microsoft-com:asm.v2″>
      <security>
      <requestedPrivileges>
      <requestedExecutionLevel
      level=”requireAdministrator”
      uiAccess=”false”/>
      </requestedPrivileges>
      </security>
      </trustInfo>
      </assembly>
       

    2. Save the file as <your app name >.exe.manifest into the res folder of your project.

    3. Click Project submenu, select Properties command in your Visual Studio IDE.

    4. In Properties, select Manifest Tool command, and then selectInput and Output.

    5. Add in the name of your application manifest file underAdditional manifest files.

    6. Rebuild your application.

    7. If you have adding the elevation script properly then you can see vista shield icon overlay with your app icon in output folder.

    8. Run the application to test the elevation. Make sure that you have not disabled the UAC for current user.

      

  • 相关阅读:
    一条语句简单解决“每个Y的最新X”的SQL经典问题
    SqlServer数据库字典--表.视图.函数.存储过程.触发器.主键.外键.约束.规则.sql
    SqlServer数据库字典--索引.sql
    SqlServer2005或2008数据库字典--表结构.sql
    SqlServer2000数据库字典--表结构.sql
    sqlserver附加 mdf、ldf的方法(手记)
    收缩数据库 DBCC SHRINKFILE
    日志、字段备注查询、自增ID联系设置、常用存储过程
    常用sql 全记录(添加中)
    python类的继承和多态,获取对象信息
  • 原文地址:https://www.cnblogs.com/phyking/p/4456630.html
Copyright © 2011-2022 走看看