为管理员权限请求添加清单 [英] Adding manifest for admin rights request
问题描述
为了简化这个,我想要给出一个管理权限nag屏幕,而不是试图解释如何右键单击程序文件/快捷方式。
我发现了一个相当不错的文章,但是我添加了自己的清单资源文件后,我收到重复的资源错误。
这被认为是由于与内部清单的冲突,并解决了我看到的问题许多建议在项目选项中禁用启用运行时主题的注释。我已经经历了每个菜单,但找不到它,我现在已经被告知,它可能不是在Delphi 7中可用,并在以后的版本中引入。
如何我添加了自己的清单?
我已经评论说,将注册表编程设置不正确,应用程式管理员权限。但是,在任何情况下都包含一个UAC清单是个好主意。 requestedExecutionLevel
应该是 level =asInvoker
。 查看文档
问:为delphi 7添加管理员权限请求的清单
创建以下4个档案(2套):
(仅适用于UAC)
uac.manifest
<?xml版本=1.0encoding =utf-8standalone =yes?>
< assembly xmlns =urn:schemas-microsoft-com:asm.v1manifestVersion =1.0>
< assemblyIdentity version =1.0.0.0processorArchitecture =X86name =MyApptype =win32/>
< trustInfo xmlns =urn:schemas-microsoft-com:asm.v3>
< security>
< requestedPrivileges>
< requestedExecutionLevel level =requireAdministratoruiAccess =false/>
< / requestedPrivileges>
< / security>
< / trustInfo>
< / assembly>
uac.rc
1 24uac.manifest
(UAC + XP主题)
uac_xp.manifest
<?xml version =1.0encoding =UTF-8standalone =yes ?>
< assembly xmlns =urn:schemas-microsoft-com:asm.v1manifestVersion =1.0>
< assemblyIdentity type =win32name =MyAppversion =1.0.0.0processorArchitecture =x86/>
<依赖关系>
< dependentAssembly>
< assemblyIdentity
type =win32
name =Microsoft.Windows.Common-Controls
version =6.0.0.0
publicKeyToken =6595b64144ccf1df
language =*
processorArchitecture =*/>
< / dependentAssembly>
< / dependency>
<! - Windows Vista应用程序安全要求。 - >
< trustInfo xmlns =urn:schemas-microsoft-com:asm.v3>
< security>
< requestedPrivileges>
< requestedExecutionLevel
level =requireAdministrator
uiAccess =false/>
< / requestedPrivileges>
< / security>
< / trustInfo>
< compatibility xmlns =urn:schemas-microsoft-com:compatibility.v1>
< application>
<! - Windows 7 - >
< supportedOS Id ={35138b9a-5d96-4fbd-8e2d-a2440225f93a}/>
<! - Windows Vista - >
< supportedOS Id ={e2011457-1546-43c5-a5fe-008deee3d3f0}/>
< / application>
< / compatibility>
< / assembly>
uac_xp.rc
1 24uac_xp.manifest
添加所需的 rc
文件( uac.rc
或 uac_xp.rc
)通过项目>添加到项目菜单项目到您的项目。这将在您的项目文件中创建 {$ R}
指令:
程序Project1;
{。$ R'uac.res''uac.rc'} //仅UAC
// OR
{$ R'uac_xp.res''uac_xp.rc '} // UAC + XP主题
使用
表单,
Unit1在'Unit1.pas'{Form1};
{$ R * .RES}
begin
Application.Initialize;
Application.CreateForm(TForm1,Form1);
Application.Run;
结束。
请注意 {$ R'uac_xp.res''uac_xp.rc' }
。 Delphi将自动编译 rc
到 res
文件。
或者您可以通过编译
Delphi IDE之外。然后将 rc
文件brcc32 uac.rc {$ R'uac_xp.res'}
手动添加到您的项目中。
确保您不使用任何其他XP清单。
I have an application that writes program settings to the windows registry that is absolutely necessary so.storing to a file is not an option.
To simplify this, I would like to give an "admin privileges" nag screen instead of trying to explain how to right click on the program file/short cut.
I found a reasonably good article but I receive a duplicate resource error after adding my own resource file for the manifest.
This is supposedly due to a conflict with the internal manifest and to resolve the issue I see a lot of comments suggesting "enable runtime themes" to be disabled in project options. I have gone through every menu but cannot find it and I've now been told that it may not be available in Delphi 7 and was introduced in later versions.
How can I add my own manifest?
I already commented that "Writing program settings to the registry is not a proper cause to give your application admin privileges". However it is a good idea to include a UAC manifest in any case. the common requestedExecutionLevel
should be level="asInvoker"
. see the docs
"Q: Adding manifest for admin rights request for delphi 7"
Create the below 4 files (2 sets):
(UAC Only)
uac.manifest
<?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="MyApp" type="win32"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
uac.rc
1 24 "uac.manifest"
(UAC + XP Themes)
uac_xp.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="MyApp" version="1.0.0.0" processorArchitecture="x86"/>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="*"/>
</dependentAssembly>
</dependency>
<!-- Windows Vista application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--Windows 7-->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--Windows Vista-->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
</application>
</compatibility>
</assembly>
uac_xp.rc
1 24 "uac_xp.manifest"
Add the desired rc
file (uac.rc
or uac_xp.rc
) to your project via the "Project > Add to project" menu item. This will create the {$R}
directive in your project file:
program Project1;
{.$R 'uac.res' 'uac.rc'} // UAC only
// OR
{$R 'uac_xp.res' 'uac_xp.rc'} // UAC + XP Themes
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
Note the {$R 'uac_xp.res' 'uac_xp.rc'}
. Delphi will auto compile the rc
to res
file.
Alternatively you can compile the rc
file via brcc32 uac.rc
outside Delphi IDE. and then add {$R 'uac_xp.res'}
manually to your project.
Make sure you don't use any other XP manifest.
这篇关于为管理员权限请求添加清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!