Get OUTLOOK full path hosting my addin?

Add-in Express™ Support Service
That's what is more important than anything else

Get OUTLOOK full path hosting my addin?
 
Byung Kun Kim


Guest


I tried to get outlook full path hosting my addin, like below:


MessageBox.Show(System.Reflection.Assembly.GetExecutingAssembly().Location)
MessageBox.Show(System.Reflection.Assembly.GetCallingAssembly().Location)
MessageBox.Show(System.Reflection.Assembly.GetEntryAssembly().Location)


But I couldn't get what I want.

How can I get currently addin hosting outlook's full path like this:

"C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE"

I can think of use System.Diagnostics.Process, what is the best way?
Posted 24 Nov, 2016 14:10:44 Top
nwein




Posts: 577
Joined: 2011-03-28
hostPath = null;
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionApp PathsOUTLOOK.EXE"))
{
	if (key != null)
	{
		object value = key.GetValue("Path");
		if (value is string)
			hostPath = value as string;
		key.Close();
	}
}
Posted 24 Nov, 2016 15:03:29 Top
Byung Kun Kim


Guest


Thank you nwein,

Your tip gives me a hint, but I wonder if user's machine has two versions of Office installed side by side. (ex, office 2013 and 2016), how the registry looks?

I want to know exactly current running my addin's host application path. That's why I tried "Assembly.Get.." stuffs to achieve.

How can I approach it?
Posted 24 Nov, 2016 15:15:26 Top
nwein




Posts: 577
Joined: 2011-03-28
I believe ADX strongly advise not to have such configuration (i.e. 2 office versions installed side by side). Getting the host name would probably be the least of your worries in such scenario.
Posted 24 Nov, 2016 15:55:07 Top
Byung Kun Kim


Guest


Found what I wanted.



Application.ExecutablePath
Posted 25 Nov, 2016 03:49:51 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Hello Byung,

Byung Kun Kim writes:
but I wonder if user's machine has two versions of Office installed side by side


Having several Office versions installed on the same machine may produce problems that cannot be solved programmatically. Say, one of the typical requirements for such configurations is: you must install Office versions in the natural order. You may want to check https://support.microsoft.com/en-us/kb/290576.

Thank you, Nir!


Andrei Smolin
Add-in Express Team Leader
Posted 25 Nov, 2016 09:28:23 Top