How to run Delphi Application as Administrator in Windows 7? [Edit]

My English is poor, I hope you can understand what i say.
I Have a Applicatioin Developed by Delphi 2009 in Winows XP sp3. Now, I need to run it in Winodows 7 and write a few files. 
So I Need this Application run as Administrator,or else it will raise an error when write a file.
what should i do?

Edited by: chen yaopan on Sep 7, 2010 10:27 PM
0
chen
9/8/2010 5:28:31 AM
embarcadero.delphi.deployment 422 articles. 0 followers. Follow

5 Replies
11561 Views

Similar Articles

[PageSpeed] 42
Get it on Google Play
Get it on Apple App Store

> {quote:title=chen yaopan wrote:}{quote}
> My English is poor, I hope you can understand what i say.
> I Have a Applicatioin Developed by Delphi 2009 in Winows XP sp3. Now, I need to run it in Winodows 7 and write a few files. 
> So I Need this Application run as Administrator,or else it will raise an error when write a file.
> what should i do?
> 
> Edited by: chen yaopan on Sep 7, 2010 10:27 PM

Step 1: 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

+Remember to change name="YourApplicationExeName" in the XML to reflect your exe's name ans well as the name of the .manifest file+

Step2:

Create a text file with following content: 

1 24 "YourApplicationName.manifest" 

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

Step 3: Open a Command Prompt Window and cd to the directory where the files are stored.

Run the command:

brcc32 RequestAdmin.RC -foRequestAdmin.RES 

This will create a new resource file called RequestAdmin.RES 

Make sure the .manifest, .rc and ,res files are in the same folder as your projects .dpr file.

Step 4: Include this resource file into the DPR of you application: 

{$R 'RequestAdmin.RES' 'RequestAdmin.RC'} 

Finally build your application - it is now ready to get admin rights on Windows Vista.
0
Nigel
9/24/2010 11:08:44 PM
> {quote:title=chen yaopan wrote:}{quote}
> My English is poor, I hope you can understand what i say.
> I Have a Applicatioin Developed by Delphi 2009 in Winows XP sp3. Now, I need to run it in Winodows 7 and write a few files. 
> So I Need this Application run as Administrator,or else it will raise an error when write a file.
> what should i do?
> 
> Edited by: chen yaopan on Sep 7, 2010 10:27 PM

Hello

I same you in language english .... 

I tried this from 2 months But to no avail ... 

always delphi 2010 show to me this error

"[DCC Warning] W1056 Warning: Duplicate resource:  Type 24 (user-defined), ID 1; File C:\Users\Abutayeh\Desktop\Admin\RequestAdmin.RES resource kept; file C:\Users\Abutayeh\Desktop\Admin\Kaxmav.res resource discarded."
I tired of manifest

thanks
....
0
Abutayeh
9/25/2010 9:12:00 AM
> {quote:title=Abutayeh Al-hoity wrote:}{quote}
> > {quote:title=chen yaopan wrote:}{quote}
> > My English is poor, I hope you can understand what i say.
> > I Have a Applicatioin Developed by Delphi 2009 in Winows XP sp3. Now, I need to run it in Winodows 7 and write a few files. 
> > So I Need this Application run as Administrator,or else it will raise an error when write a file.
> > what should i do?
> > 
> > Edited by: chen yaopan on Sep 7, 2010 10:27 PM
> 
> Hello
> 
> I same you in language english .... 
> 
> I tried this from 2 months But to no avail ... 
> 
> always delphi 2010 show to me this error
> 
> "[DCC Warning] W1056 Warning: Duplicate resource:  Type 24 (user-defined), ID 1; File C:\Users\Abutayeh\Desktop\Admin\RequestAdmin.RES resource kept; file C:\Users\Abutayeh\Desktop\Admin\Kaxmav.res resource discarded."
> I tired of manifest
> 

You will have to uncheck Enable runtime themes in Project Options, 
because it adds a manifest of its own, and use slightly different manifest that
also includes themes support.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">

  <assemblyIdentity
  	type="win32"
    name="DelphiApplication"
    version="1.0.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.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"/>
        </requestedPrivileges>
       </security>
  </trustInfo>

</assembly>

Dalija Prasnikar
0
Dalija
9/25/2010 9:30:50 AM
<Abutayeh Al-hoity> wrote in message news:289561@forums.embarcadero.com...

> always delphi 2010 show to me this error
>
> "[DCC Warning] W1056 Warning: Duplicate resource:  Type 24 (user-defined), 
> ID 1; File C:\Users\Abutayeh\Desktop\Admin\RequestAdmin.RES resource kept; 
> file C:\Users\Abutayeh\Desktop\Admin\Kaxmav.res resource discarded."

You cannot assign the same resource ID to multiple resources.  If you want 
to provide your own manifest resource, then you need to disable the "Use 
runtime themes" option in the Project Options first.

> I tired of manifest

Tired or not, Windows still requires them, you are best off learning how to 
work with them correctly.

-- 
Remy Lebeau (TeamB)
0
Remy
9/27/2010 6:57:55 PM
<Dalija Prasnikar> wrote in message news:289565@forums.embarcadero.com...

> You will have to uncheck Enable runtime themes in Project
> Options, because it adds a manifest of its own, and use slightly
> different manifest that also includes themes support.

Personally, I would love to see the default resource eliminated and a new 
Manifest Editor added to the IDE.  Then users can safely and correctly 
provide their own per-project manifests.  The default manifest simply does 
not support everything that manifests can do anymore.

-- 
Remy Lebeau (TeamB)
0
Remy
9/27/2010 6:59:37 PM
Reply: