I need to detect programmatically if Microsoft Excel 2016 (normal Office flavor) or Microsoft Excel (Office 365 flavor) is installed.
Detecting Microsoft Excel 2016 (normal Office flavor) is no problem it works fine, but detecting Excel Office 365 is a bit more trickier.
What I do now:
- I check if the registry key
HKEY_CLASSES_ROOT\.xlsmm\OpenWithProgids
- then I enumerate the values in that key (usually there is only one value of the form
"AppXdns5t4sbk...."
) - for each of these values I open the "HKEY_CLASSES_ROOT\\Application" key and I check if the value ApplicationName" is "Excel", and if yes I suppose Excel Office 365 is installed.
This is quite hacky, and if anybody knows a cleaner way, I'd be grateful to learn about it.
Edit:
The reason I need this:
My software allows the user to generate an Excel file (using a 3rd party library) and then view that file in Excel. Once the processing is done and
When I simply try to open the .xls file with
ShellExecuteEx
and Excel is not installed, then the Windows 10 standard "How do you want to open this file" dialog pops up.Even if
ShellExecuteEx
returned an error message instead of popping up the Windows 10 dialog (as described before), this behaviour is not really what I want, because the generation of the .xls file is pretty long and following would happen: The user executes the command that generates the Excel File, this takes 10 - 15 seconds, and then an error message would pop up saying that Excel is not installed. I'd rather tell the user beforehand that Excel needs to be installed.