【问题标题】:How to force Compatibility-mode for Windows 8 when ClickOnce application is executed执行 ClickOnce 应用程序时如何强制 Windows 8 的兼容模式
【发布时间】:2020-08-19 21:19:00
【问题描述】:

我开发的 ClickOnce 应用程序有问题:在某些 Windows 10 版本上,ClickOnce 客户端已下载,由 .net 框架执行,但没有显示任何内容。

如果我进入任务管理器,选择进程,打开详细信息,选中复选框“以 Windows 8 的兼容模式运行此程序”,它工作正常。

由于我不希望每个客户端都执行此操作,因此我正在寻找一种方法来强制 ClickOnce 客户端在 Windows 8 启动时以这种兼容模式执行。

我检查了很少的文档,并将应用程序的清单更改为:

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
  <!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
  <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
</application>

我再次测试,但 ClickOnce 客户端没有以正确的兼容模式启动。

有没有办法实现我想做的事情?

谢谢!

【问题讨论】:

    标签: clickonce compatibility-mode


    【解决方案1】:

    Microsoft 团队的某个人在 social.msdn 上非常有效地支持了我,所以我将在此报告解决方案:

    我们需要更改注册表设置一个key=value,其中 - key 是可执行文件的路径 - 值为“WIN8RTM”。

    在 clickonce 应用程序中,在开始任何操作之前,我会调用以下函数:

    void ForceWin8RTM() {
    try {
        RegistryKey^ key = Registry::CurrentUser->OpenSubKey("SoftWare\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", true);//Open the registry subkey
        System::String^ EXEName = System::Reflection::Assembly::GetExecutingAssembly()->Location;
    
        //If the item does not exist, create the sub-item 
        if (key == nullptr) 
        {
            key = Registry::CurrentUser->CreateSubKey("SoftWare\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers");            
        }
        //If the value does not exist, set the value and restart the program to apply the setting
        if (key->GetValue(EXEName) == "" || key->GetValue(EXEName) == nullptr)
        {
            key->SetValue(EXEName, "WIN8RTM");
            Application::Restart();
        }
    } catch(Exception^ e) {
    }
    

    }

    这里是msdn上的帖子链接:https://social.msdn.microsoft.com/Forums/en-US/056c7bf1-797f-4af7-83e2-d88b979e58a6/how-to-force-compatibilitymode-for-windows-8-whenclickonce-application-is-executed?forum=winformssetup

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 2013-11-29
      • 1970-01-01
      相关资源
      最近更新 更多