【问题标题】:How to programmatically discover whether the running application is installed? [closed]如何以编程方式发现正在运行的应用程序是否已安装? [关闭]
【发布时间】:2012-10-06 20:28:26
【问题描述】:

我希望程序检查它是安装在计算机上(使用 Clickonce)还是正在运行(例如通过 Visual Studio)。

编辑:不是 How to detect that C# Windows Forms code is executed within Visual Studio? 的副本。 “例如。”表示for example。

【问题讨论】:

  • @downvoter 想解释一下为什么?明显的答案? (嗯,我不知道。)通过搜索很容易找到? (先试试。我试过了。)
  • (不是反对者)这是一个网站还是一个 winforms 应用程序?如果是后者,看这个问题:stackoverflow.com/questions/2427381/…
  • @BobKaufman 添加了标签 - Winforms。 (重要吗?)
  • 感谢您的提议,但我不能将别人的工作归功于我。如果该问题中的一个答案对您有所帮助,请务必支持该答案! :)
  • @BobKaufman,我希望你能把你的最后一条评论作为答案,我会投赞成票,这真的成了一个问题。无论出于何种原因,SO 似乎都变成了一种竞争,而不是一个社区。​​span>

标签: c# winforms visual-studio-2010 clickonce


【解决方案1】:

您可以使用ApplicationDeployment.IsNetworkDeployed 属性。请注意,这只适用于 ClickOnce 安装。

private void CheckApplicationStatus() {
    if (ApplicationDeployment.IsNetworkDeployed) {
        // Do something that needs doing when the application is installed using ClickOnce.
    } else {
        // Do something that needs doing when the application is run from VS.
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-23
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 2011-10-17
    • 2011-06-18
    • 1970-01-01
    相关资源
    最近更新 更多