With previous versions of VS you could query the registry to determine the installation directory for VS:
HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Visu
Visual Studio 2017 supports no-registry, side-by-side installations of all SKUs (Enterprise, Professional and Community).
MSI installlers can query via APIs described here: https://blogs.msdn.microsoft.com/heaths/2016/09/15/changes-to-visual-studio-15-setup/
Examples are here: