如何以编程方式阻止“程序兼容性助手"在 Vista(和 Windows 7)中出现? [英] How do I prevent programmatically the "Program Compatibility Assistant" in Vista (and Windows 7) from appearing?

查看:23
本文介绍了如何以编程方式阻止“程序兼容性助手"在 Vista(和 Windows 7)中出现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个可能使用 adobe flash 的 C++ 程序,尽管它不是必需的.
我使用 CoCreateInstance 创建 flash 对象,如果失败,我知道没有安装 flash,所以我不使用它.
但是,在 Vista(我认为 Windows 7 也是如此)中,当未安装 Flash 时,离开应用程序后,程序兼容性助手"会弹出一条消息,指出此程序需要缺少 Windows 组件"指定了 Flash.ocx.

有没有办法防止出现此消息?我不想强迫任何用户安装 Flash(特别是因为它是 IE ActiveX,而 FireFox 用户可能没有安装它),而且我的应用程序可以在没有 Flash 的情况下运行良好.
此外,每次运行后都会出现此消息,这真的很烦人.
我当然不是说在用户机器上禁用 PCA,而是在所有机器上以编程方式禁用此特定外观.

I develop a C++ program which might use adobe flash, although it is not essential.
I use CoCreateInstance to create the flash object, and if it fails, I know flash is not installed so I don't use it.
However, in Vista (and I think Windows 7 as well), when flash is not installed, after leaving the application, the "Program Compatibility Assistant" pops up a message saying that "This program requires a missing Windows component" specifying the flash.ocx.

Is there a way to prevent this message from appearing? I don't want to force any user to install flash (especially since it's the IE ActiveX, and FireFox users might not have it installed), and my application can operate well without the flash.
Plus this message is really annoying when it appears after every run.
I don't mean of course disabling the PCA on the user's machine, but programmatically disable this specific appearance on all machines.

有什么想法吗?
谢谢

Any thoughts?
Thanks

我遵循了 Shay 的指导(谢谢),并自己进行了更多的挖掘.我将以下 XML 添加到应用程序的清单中:

I followed Shay's lead (thanks), and did some more digging of my own. I added the following XML to the application's manifest:

<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
  <security>
    <requestedPrivileges>
      <requestedExecutionLevel level="asInvoker" uiAccess="false">
      </requestedExecutionLevel>
   </requestedPrivileges>
  </security>
</trustInfo>

(另见:msdn.microsoft.com/en-us/library/bb756929.aspx)
这解决了 Vista 64 上的问题.

(see also: msdn.microsoft.com/en-us/library/bb756929.aspx)
This solved the problem on Vista 64.

为了在 Windows 7 上解决同样的问题,我添加了以下内容:

To solve the same problem on Windows 7, I added the following:

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
  <application>
    <!--The ID below indicates application support for Windows Vista -->
    <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
    <!--The ID below indicates application support for Windows 7 -->
    <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
  </application>
</compatibility>

(另见:blogs.msdn.com/yvesdolc/archive/2009/09/22/the-new-compatibility-section-in-the-application-manifest.aspx)

解决了 Windows 7.

Solved Windows 7.

但出于某种原因,它仍然会在 Vista 32 中发生...

But for some reason, it still happens in Vista 32...

我还尝试编辑导致问题的特定 DLL 的清单,但没有任何效果.只有可执行文件的清单本身影响了问题.

I also tried editing the manifest of the specific DLL which causes the problem, but it had no effect. Only the executable's manifest itself affected the problem.

那么……Vis​​ta 32?

So... Vista 32?

推荐答案

摘自 此处(讨论设置但与您的情况相关)

Snippet from here (Talks about setup but relevant to your case)

如何为我的计算机选择退出程序兼容性助手设置?

为了防止程序兼容性助手来自出现时,您必须包含一个指定一个的嵌入式清单为您请求的执行级别设置可执行文件.如果你包裹在自解压中设置可执行文件包,您还必须包含一个嵌入清单中也是自解压包.一旦您这样做,Windows Vista 将处理您的设置为 Windows Vista-aware,并且它将不再显示 PCA 对话框当安装程序在失败或失败后退出时取消.

In order to prevent the Program Compatibility Assistant from appearing, you must include an embedded manifest that specifies a requested execution level for your setup executable. If you wrap the setup executable in a self-extracting package, you must also include an embedded manifest in the self-extracting package too. Once you do this, Windows Vista will treat your setup as Windows Vista-aware, and it will no longer show the PCA dialog when setup exits after a failure or cancellation.

这篇关于如何以编程方式阻止“程序兼容性助手"在 Vista(和 Windows 7)中出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆