日期:2014-05-18  浏览次数:20702 次

请教关于vs2005 写的程序在win7上运行时的管理员权限问题
用vs 2005写的一个Windows程序。
在winxp上一直都正常,但是在win7上就不行。后来发现在win7右键以管理员权限运行就没有问题。

请问一下,怎么能通过修改程序或者修改配置文件来解决这个问题而不需要每次以管理员权限运行。

------解决方案--------------------
直接想绕过UAC,不太好办,可以给你的exe配个manifest文件
比如你的程序名称是 MyApp.exe, 复制以下xml,在相同目录下生成一个MyApp.exe.manifest文件

XML code

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.0.0.0"
  processorArchitecture="X86"
  name="MyApp"
  type="win32" />
  <description>MyApp for UAC support</description>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>