How do I prevent programmatically the “Program Compatibility Assistant” in Vista (and Windows 7) from appearing?

喜欢而已 提交于 2020-01-20 06:07:29

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/1587962/how-do-i-prevent-programmatically-the-program-compatibility-assistant-in-vista

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!