If you are addin developer for any Microsoft product, you might have in need to find out the exact version no. of the office product. You can get it from the app version from the interop libraries, but that doesn't return the correct one to you.
So, how to retrieve it? Today in this small post, we will find out the way to get the correct version no. If you know any alternate way, will highly appreciate if you do share it with us.
Retrieving the version no. from the interop assembly is not fruitful as it doesn't return the correct one that office product has or Microsoft lists in their product update page. To find out the right version no. (x.x.x.x), we need to read the FileVersionInfo from the executable file of the product.
There comes a challenge! We can't assure a fix location of the installed product. To read the installed path of the product, we need to read it from the memory.
Microsoft provides a separate registry location "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" for 32-bit applications and "SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths" for 64-bit applications, where all the application paths are listed by their names. For example, outlook path is listed here in the registry: "SOFTWARE\[WOW6432Node]\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE".
From this path retrieved from Windows registry, you can easily find out the file's version information and extract the correct version from it.
If you want to read it using C#, here is the code snippet that you can use:
This will help you to find out the correct office product version. I have used "outlook.exe" but you can change it to excel or word too. I hope, you liked the post. If you have any issues further or have any queries, do let me know. Also, I will appreciate if you can share some other alternate ways to get this correct version no.