How to add manifest <requestedPrivileges> info into delphi project

依然范特西╮ 提交于 2019-11-26 10:57:54

问题


What is the easiest way to add the <requestedPrivileges> manifest info to a Delphi XE project (.exe)?

Is it possible to add just the required node like:

<requestedPrivileges>   
  <requestedExecutionLevel level=\"requireAdministrator\"/> 
</requestedPrivileges>

or do i have to add the whole manifest file, like?

<?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=\"VistaLogonCustomizer.exe\" type=\"*\"/>
  <description>elevate execution level</description>
  <trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v2\">
   <security>
     <requestedPrivileges>
      <requestedExecutionLevel level=\"requireAdministrator\"/>
     </requestedPrivileges>
   </security>
  </trustInfo>
  <dependency>
   <dependentAssembly>
     <assemblyIdentity type=\"win32\" name=\"Microsoft.Windows.Common-Controls\" version=\"6.0.0.0\" publicKeyToken=\"6595b64144ccf1df\" language=\"*\" processorArchitecture=\"*\"/>
   </dependentAssembly>
  </dependency>
</assembly> 

If I have to add the whole manifest file, do I have then a conflict with the build in manfest file (which is generated when the project-option \"Activate Runtime-Theme\" is set to true)?


回答1:


Is it possible to add just the required node

Absolutely NO. Manifest is an XML document and XML documents must be well-formed. Here is XML schema description:

http://msdn.microsoft.com/en-us/library/aa374191(VS.85).aspx

Note the required elements and attributes.




回答2:


Here are some links

Delphi and Windows Vista User Account Control

Vista UAC Manifest

Here are the steps:

Create XML file with following content: 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.1.1.1"
   processorArchitecture="X86"
   name="YourApplicationExeName"
   type="win32"/>
  <description>elevate execution level</description>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
  <security>
   <requestedPrivileges>
    <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
   </requestedPrivileges>
  </security>
  </trustInfo>
 </assembly>

Name this XML file as YourApplicationName.manifest

Create a text file with following content:

1 24 "YourApplicationName.manifest"

Name this text file as YourApplicationName.RC using the command line execute following command:

brcc32 YourApplicationName.RC -foYourApplicationName.REC

This will create a new resource file called YourApplicationName.REC Copy this YourApplicationName.REC file in to the resource path of your application. Include this resource file into the DPR of you application,

as like:

{$R YourApplicationName.REC} Finally build your application - it is now ready to get admin rights




回答3:


You should add the entire manifest. You'll need to disable the IDE generated version in the project.

The advantage of this is that you will have full and transparent control of your manifest. For example you may want to add a DPI aware entry so that your app looks good at higher font scaling values.



来源:https://stackoverflow.com/questions/6226976/how-to-add-manifest-requestedprivileges-info-into-delphi-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!