在Vista操作系统中通过manifest文件使VC应用程序获得管理员权限

来源:互联网 发布:歌曲梦里花落知多少 编辑:程序博客网 时间:2024/05/16 13:42

这是我在项目中遇到的,项目中的服务器在VC2005和XP环境下开发的,没有加MANIFEST文件,使得在VISTA下当服务器时出现外面的客户端无法访问的问题,问我师傅,才知道是要添加manifest文件来使得VC应用程序获得管理员权限,(*^__^*) 嘻嘻

问题也就解决了。

1.打开应用程序的源代码工程

2.添加一个“custom”资源,"resource type"填24,把资源ID改为1,然后把以下内容复制到资源内容中保存为一下内容

<?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="mulitray.exe.manifest"
  type="win32"
/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  <security>
    <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
    </requestedPrivileges>
  </security>
</trustInfo>
</assembly>

 

3.重新编译应用程序就OK了

 

注意以上xml复制下来如果有中文标点符号要改成英文的标点符号,要不会提示 "并行配置错误"。

 

参考于:http://www.debugman.com/read.php?tid=325