【问题标题】:open project in delphi as administrator以管理员身份在delphi中打开项目
【发布时间】:2018-01-24 18:07:19
【问题描述】:

在 Delphi XE3 -> 项目选项 -> 应用程序中,设置自定义清单 用 C:\Program Files\MyProject\Win7UAC.manifest, 但是如果系统安装在 C:\Program Files\MyProject 以外的目录下,项目不会以管理员身份打开。

无论要安装的路径如何,如何将项目配置为以管理员身份打开?

Win7UAC.manifest

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity type="win32" name="orion.exe" version="3.1.0.0" processorArchitecture="*"/>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*"/>
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
    <applicationRequestMinimum>  
      <PermissionSet ID="FullTrust" Unrestricted="true" />  
      <defaultAssemblyRequest permissionSetReference="FullTrust" />  
    </applicationRequestMinimum>    
    </security>
  </trustInfo>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!--The ID below indicates application support for Windows Vista -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
      <!--The ID below indicates application support for Windows 7 -->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
    </application>
  </compatibility>
</assembly>

【问题讨论】:

  • 你能告诉我们你的清单文件吗?
  • 安装位置与应用是否需要提升无关。
  • 我需要在项目选项 -> 应用程序 -> 自定义清单中动态路径,因为我不知道用户将在哪里安装应用程序
  • @alice 您误解了该选项的作用。您指定的路径是编译项目时清单文件在开发机器上的位置。然后将清单的内容编译为您提供给用户的最终 EXE 的资源。清单文件不需要部署给用户。
  • 但是当我把project.exe和manifest文件放在同一个目录时,项目以管理员身份运行,当我把它放在另一个目录时,它不能以管理员身份运行

标签: delphi manifest delphi-xe3


【解决方案1】:

您的清单缺少 requestedExecutionLevel 元素。您需要将其添加到您的 trustInfo 元素中,例如:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity type="win32" name="orion.exe" version="3.1.0.0" processorArchitecture="*"/>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*"/>
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <applicationRequestMinimum>
        <PermissionSet ID="FullTrust" Unrestricted="true" />
        <defaultAssemblyRequest permissionSetReference="FullTrust" />
      </applicationRequestMinimum>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!--The ID below indicates application support for Windows Vista -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
      <!--The ID below indicates application support for Windows 7 -->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
    </application>
  </compatibility>
</assembly>

【讨论】:

    猜你喜欢
    • 2017-04-21
    • 1970-01-01
    • 1970-01-01
    • 2022-12-03
    • 2012-07-14
    • 2012-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多