WinXP和Win7下Delphi应用程序清单文件问题
我的最后一个问题“列出 Win-7 下的服务和服务状态”让我开始研究一个解决方案,该解决方案根据 .manifest 文件为我的应用程序提供 Windows Vista 及更高版本下的管理权限。
我不确定是否要继续上一个问题,因为它们不一样,所以这是另一个问题:
我的应用程序现在在 Win 7 下工作正常,无论我是否因为清单文件而“以管理员身份”运行它。 我的清单文件如下:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.6.0.5" processorArchitecture="X86" name="ServiceMonitorPro" type="win32"/>
<description publisher="Powershield Ltd" product="Powershield Service Monitor">Powershield Service Monitor</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
当应用程序在 Windows 7 或 Vista 上运行时,UAC 会出现如下对话框: 替代文本 http://www.freeimagehosting.net/uploads/39787fd3dd.jpg
如何我可以更换“未知”的发布者吗?
另一个最大的问题是,即使应用程序在 Win7 或 Vista 下运行没有问题,但在 WinXP 下它现在崩溃并显示以下消息: “此应用程序无法启动,因为应用程序配置不正确。重新安装应用程序可能会解决此问题。”
我想补充的另一件事:如果 我向 XPMan 添加引用(使用子句) 该应用程序在 WinXP 上运行良好,但随后 我的 .manifest 文件没有 Vista和Win7下的区别。
My last question "List service and services status under Win-7" made me start working on a solution that gives my app the admin privileges under Windows Vista onward based on a .manifest file.
I was not sure about continue the previous question with this matter since they are not the same so here is another question:
My app now works fine under Win 7 whether or not I run it "as admin" because of the manifest file.
My manifest file is as follow:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.6.0.5" processorArchitecture="X86" name="ServiceMonitorPro" type="win32"/>
<description publisher="Powershield Ltd" product="Powershield Service Monitor">Powershield Service Monitor</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
When the application runs on windows 7 or Vista, the UAC comes with a dialog like this:
alt text http://www.freeimagehosting.net/uploads/39787fd3dd.jpg
How can I replace the "unknow" publisher?
The other and bigest problem is, even thou the app runs with no problem under Win7 or Vista, under WinXP it is now crashing with the message:
"This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem."
Another thing I would like to add: If
I add reference (uses clause) to XPMan
the app works fine on WinXP but then
it my .manifest file makes no
diference under Vista or Win7.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我必须感谢每个人,他们的评论或答案让我继续挖掘......:)
我去搜索文件WindowsXP.res。
该文件的内容是:
解决方案: 我已将 .manifest 文件与添加 依赖项 部分的 WindowsXP.Res xml 文件混合在一起。
如果有人知道为什么它现在可以工作,我会很高兴听到 - 但这是这里的解决方案 - 到目前为止在几个虚拟机、我的计算机和其他几个计算机上进行了测试......工作:)
I have to thank everyone that, with comments or answers point me to keep digging... :)
I went to search for the file WindowsXP.res.
The content of that file is:
The solution: I have mixed my .manifest file with the WindowsXP.Res xml one adding the dependency section.
If anyone know why its now working, I would be glad to hear about - but this was the solution here - tested so far in a couple of virtual machines, on my computer and a couple of others... working :)
您需要使用代码签名证书对代码进行签名。这里应该有很多例子。我已经用“代码签名”重新标记了您的问题,您也可以查找“证书”。
我自己使用 Comodo 证书,并使用令人惊叹的 Visual Build Pro v6 对其进行签名,该版本是 SO 上的广告商。
You need to sign your code with a code signing certificate. There should be lots of examples here. I have re-tagged your question with "code-signing", and you can also look for "certificate".
I use Comodo certs myself, and sign them with the awesome, wonderful, Visual Build Pro v6, which is an advertiser here on SO.
您还可以在清单中指示与各种版本的 Windows 的兼容性。我知道有兼容Vista和Win7的条目;不确定XP。
有关清单兼容性部分的信息,请访问 MSDN。这也可能有帮助 - 从链接页面:
You can indicate compatibility with various versions of Windows in your manifest as well. I know that there are entries for compatibility with Vista and Win7; not sure about XP.
Info about the manifest compatibility section is available at MSDN. This may help, also - from the linked page:
在较新版本的 Delphi(我认为是 7 及更高版本)上,您还需要确保取消选中项目选项对话框中的“使用运行时主题”选项,否则 Delphi 将自动链接到其自己的默认清单文件中(这就是它启用的方式) “主题支持”),您将收到有关应用程序配置不正确的运行时错误,因为存在冲突的条目。
以下是 Delphi2007 应用程序的完整清单文件,该应用程序需要在 Windows 7 中以管理员模式运行,并且还包含“依赖项”部分以启用运行时主题支持:
On newer versions of Delphi (7 and above I think) you also need to also be sure to uncheck the "Use Runtime Themes" option in your project options dialog, otherwise Delphi will automatically link in its own default manifest file (that's how it enables the "theme support") and you will get a runtime error about the application's configuration being incorrect, because there will be conflicting entries.
Here's a complete manifest file for a Delphi2007 app which needs to run in adminstrator mode in Windows 7, and also includes the "dependency" section to enable runtime theme support: