Byung Kun Kim
Posts: 48
Joined: 2011-12-15
|
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? |
|
nwein
Posts: 518
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();
}
} |
|
Byung Kun Kim
Posts: 48
Joined: 2011-12-15
|
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? |
|
nwein
Posts: 518
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. |
|
Byung Kun Kim
Posts: 48
Joined: 2011-12-15
|
Found what I wanted.
Application.ExecutablePath
|
|
Andrei Smolin
Add-in Express team
Posts: 15595
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!
Regards from Belarus (GMT+3),
Andrei Smolin
Add-in Express Team Leader |
|