如何以编程方式发现正在运行的应用程序是否已安装?

时间:2012-10-16 16:58:37

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

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

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

1 个答案:

答案 0 :(得分:3)

您可以使用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.
    }
}