Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've eventually also figured out a way to check if the application is upgrading or if it is a fresh install:</p> <ul> <li>The application leaves some information about itself in the registry (application name, version number etc.). This is usually stored within </li> </ul> <blockquote> <p>LocalMachine\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{Application's GUID}</p> </blockquote> <p>When the application is uninstalled that information is removed.</p> <ul> <li>But you can check for that information when you are installing a version of your application (this can be done by adding some custom actions in the deployment project). I check it under the <strong>BeforeInstall</strong> method and look in the registry for the <strong>DisplayVersion</strong> value, like so:</li> </ul> <pre><code> RegistryKey regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{AppGUIDHere}"); string version = (string)regKey.GetValue("DisplayVersion"); </code></pre> <ul> <li><p>This value will contain the version that is currently installed on your computer. If this installed version is smaller than the version of the application you are trying to install, then you follow the logic path of UPGRADING</p></li> <li><p>If you can't find anything in the registry under that key, that means that this is a fresh install (there is no other application before this one installed on the computer). And here you follow the other logic path of just installing</p></li> </ul> <p>Hope this helps somebody.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload