vista中用vc弹出UAC窗口
来源:优易学  2011-12-5 11:34:03   【优易学:中国教育考试门户网】   资料下载   IT书店
  公司产品发先个问题,在vista guest用户居然注册flash.ocx会失败,而且不提示任何错误,但是在windows会成功,就直接弄了个exe,安装的时候居然弹出UAC,要输入密码才能继续往下运行,而公司的产品注册是却不会弹出,后来才知道guest用户不够权限,要弹出UAC输入密码提高权限.
  在网上找了很久,很多都是讲delphi,看想去挺麻烦的,也看到些vc的,发现有两种简单的方法可以做到让exe弹出UAC:
  1.直接更改exe名,vista下系统遇到这些update install..敏感,会马上弹出UAC;
  2.就是在资源里面添加些东东了。
  <?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="test.exe.manifest"
  type="win32"
  />
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  <security>
  <requestedPrivileges>
  <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
  </requestedPrivileges>
  </security>
  </trustInfo>
  </assembly>
  该代码添加到VC资源中即可, 添加方式:
  添加一个“custom”资源,”resource type”填24,青年人网提示把资源ID改为1。
  如果只有一个可执行文件,也可以通过以下方法添加:
  mt.exe -manifest e4nmgr.exe.manifest -outputresource:e4nmgr.exe;1
  这样,就可以在C++编译出来的程序里面实现申请管理员权限那个功能了。

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训