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

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

问题描述

我开发一个可能使用adobe flash的C ++程序,虽然这不是必需的。

我使用CoCreateInstance来创建flash对象,如果失败,我知道flash没有安装,所以我不使用它。

然而,在Vista(我认为Windows 7也是如此),当没有安装闪存时,离开应用程序后,程序兼容性助手弹出一条消息,此程序需要缺少Windows组件指定flash.ocx。


是否有办法防止此消息出现?我不想强迫任何用户安装闪存(特别是因为它是IE ActiveX,并且FireFox用户可能没有安装它),我的应用程序可以运行良好没有闪存。

加上此消息在每次运行之后出现时真的很烦人。

我当然不是在用户的计算机上禁用PCA,而是在所有计算机上以编程方式禁用此特定外观。



有任何想法吗?

感谢



b
$ b

我跟随Shay的领导(感谢),并做了一些更多的挖掘我自己。我将以下XML添加到应用程序的清单中:

 < trustInfo xmlns =urn:schemas-microsoft-com:asm。 v2> 
< security>
< requestedPrivileges>
< requestedExecutionLevel level =asInvokeruiAccess =false>
< / requestedExecutionLevel>
< / requestedPrivileges>
< / security>
< / trustInfo>

(另请参阅: msdn.microsoft.com/en-us/library/bb756929.aspx

这解决了Vista 64的问题。



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

 < compatibility xmlns =urn:schemas-microsoft-com:compatibility.v1> 
< application>
<! - 以下ID表示Windows Vista的应用程序支持 - >
< supportedos Id ={e2011457-1546-43c5-a5fe-008deee3d3f0}/>
<! - 以下ID表示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。



但是由于某些原因,它仍然发生在Vista 32 ...



我也试过编辑特定DLL会导致问题,但它没有效果。



那么... Vista 32?

解决方案

来自此处的代码段


如何选择不使用计划兼容性助理的我的
设置?



为了防止
中的程序
兼容性助手出现,您必须包含
嵌入式清单它为您的
设置可执行文件指定了一个
请求的执行级别。如果你在自解压的
包中包装
设置可执行文件,你还必须在
自解压包中包含
嵌入的清单。一旦你
这样做,Windows Vista会把你的
设置为Windows Vista感知,并且
将不再显示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

[EDIT:]

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>

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

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>

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

Solved Windows 7.

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

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.

So... Vista 32?

解决方案

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

How can I opt out of the Program Compatibility Assistant for my setup?

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天全站免登陆