tqsheng

go.....
随笔 - 366, 文章 - 18, 评论 - 101, 引用 - 0
数据加载中……

VC2005 编译Win7以管理员权限启动的可执行程序

 

VC2005 编译Win7以管理员权限启动的可执行程序

    由于在Vista、Win7系统增加了UAC功能,导致很多程序启动时需要用户以手动点击鼠标右键,选择“以管理员权限启动”来启动应用程序。

    为了方便用户,VC程序员可以自己在程序中添加以管理员权限启动的功能,其实非常简单,将以下代码复制到记事本中,保存为.manifest后缀名的文件

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>  
  2. <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">   
  3.   <assemblyIdentity version="1.0.0.0"  
  4.      processorArchitecture="X86"  
  5.      name="AnyNameYouWant"  
  6.      type="win32"/>   
  7.   <description>Description of your application</description>   
  8.   <!-- Identify the application security requirements. -->  
  9.   <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">  
  10.     <security>  
  11.       <requestedPrivileges>  
  12.         <requestedExecutionLevel  
  13.           level="requireAdministrator"  
  14.           uiAccess="false"/>  
  15.         </requestedPrivileges>  
  16.        </security>  
  17.   </trustInfo>  
  18. </assembly>  

然后进入该项目的属性对话框,选择“清单工具”的“输入与输出”,将此manifest文件附加进去重新生成即可。

posted on 2012-09-16 16:39 tqsheng 阅读(391) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理