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

查看:25
本文介绍了如何以编程方式阻止“程序兼容性助手"?在 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.

所以... Vista 32?

So... Vista 32?

推荐答案

片段来自 这里(讨论设置但与您的情况相关)

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

如何为我的用户选择退出程序兼容性助手?设置?

为了防止程序兼容性助手出现,您必须包括一个指定一个嵌入式清单为您请求的执行级别设置可执行文件.如果你把在自解压文件中设置可执行文件包,您还必须包括一个嵌入清单中自解压包也是.一旦您这样做,Windows Vista 将处理您的设置为支持 Windows Vista,并且它将不再显示 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天全站免登陆