Set $InstDir with InstallDirRegKey if the app has a registry entry you can use, probably InstallLocation or UninstallString in the Uninstall key.
A directory page with app detection forced by
http://nsis.sourceforge.net/Reference/.onVerifyInstDir
To install files you use the SetOutPath and File instructions. Use the RequestExecutionLevel attribute to control UAC...