Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't catch manifest file

Tags:

uac

delphi

My program should run as administrator. Two years ago, I create a manifest file and it works fine. But now, I transfer from Delphi 2010 to Delphi XE3 and it doesn’t work – program start as usual (not as administrator). Further I will call my program as "MyApp".

In source, I declare two res-files:

{$R MyApp.res}
{$R Manifest.res}

Manifest was create by this code:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
  <assemblyIdentity 
    type="win32" 
    name="MyApp" 
    version="1.1.0.0" 
    processorArchitecture="x86"/> 
  <description> 
    MyApp 
  </description> 
  <dependency> 
    <dependentAssembly> 
      <assemblyIdentity 
        type="win32" 
        name="Microsoft.Windows.Common-Controls" 
        version="6.0.0.0" 
        publicKeyToken="*deleted*" 
        language="*" 
        processorArchitecture="x86"/> 
    </dependentAssembly> 
  </dependency> 
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> 
    <security> 
      <requestedPrivileges> 
        <requestedExecutionLevel 
          level="requireAdministrator" 
          uiAccess="false"/> 
        </requestedPrivileges> 
    </security> 
  </trustInfo> 
</assembly>

When I delete {$R MyApp.res} from source manifest work. So I understand that MyApp.res (automatically generated by Delphi) beat Manifest.res. But in Delphi 2010 this configuration works perfect but doesn't work in XE3. Why? How I can fix it?

like image 885
m1know Avatar asked May 06 '13 03:05

m1know


1 Answers

If you want to use a custom .res file for your manifest, you need to disable Delphi's default manifest, as a process can only have 1 manifest. Go into the Project Options, in the "Application" section, and set the "Runtime Themes" option to "none".

Alternatively, move your manifest into a .manifest file, then set the "Runtime Themes" option to "use a custom manifest". Then remove your custom .res file from your code.

like image 92
Remy Lebeau Avatar answered Nov 11 '22 14:11

Remy Lebeau