Finding Outlook Version using C#

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

Finding Outlook Version using C#
need to find the version of the outlook installed in the system 
babu


Guest


Hi,
I need to find out whether the outlook installed in the system, if yes then whether it is outlook 2000 or later.

Can any one suggest me the way to find this

Thanks and Regards
babu
Posted 18 Jul, 2005 08:14:05 Top
Guest


Guest


Hi

I do a test for Office 2003 + SP1 in paticular Outlook 2003 SP1 build 11.06.6352 you can do the same but modify it for Office:

In .net go to setup project right click and choose launch conditions:

Setup a new Search Target Machine with the following:

Name = Outlook11
Depth = 5
Filename = Outlook.exe
Folder = [programFilesFolder]
MinVersion = 11.0.652
Propery = OUTLOOK.EXE

Just modify the MinVersion to what you want just right click on your Outlook.exe on your machine to get it. Also this assumes Office has been installe dot Program Files etc.

Next Create a new Launch Condition:

Name = Outlook11
Condition = OUTLOOK.EXE
Message = You can type in what you want to appear if they have the wrong version installed etc. e.g. Outlook version 11.0.6353 or later must be installed, please contact IT support.

Matt
Posted 18 Jul, 2005 08:29:04 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Babu.

You can use the following code:

private bool IsOutlookInstalled()
{
Type requestType = Type.GetTypeFromProgID("Outlook.Application", false);
if (requestType == null)
{
RegistryKey key = null;
try
{
key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Office", false);
if (key != null)
{
double version = 0.0, temp = 0.0;
string[] valueNames = key.GetSubKeyNames();
for(int i=0; i<valueNames.Length; i++)
{
temp = 0.0;
try
{
temp = Convert.ToDouble(valueNames[i],
CultureInfo.CreateSpecificCulture("en-US").NumberFormat);
}
catch
{
}
if (temp > version) version = temp;
}
key.Close();
if (version != 0.0)
requestType = Type.GetTypeFromProgID("Outlook.Application."+version.ToString().Replace(",", "."), false);
}
}
catch
{
if (key != null) key.Close();
}
}
return (requestType != null);
}

private int GetOfficeVersion()
{
RegistryKey key = null;
try
{
key = Registry.ClassesRoot.OpenSubKey("Outlook.Application\\CurVer", false);
if (key != null)
{
string version = key.GetValue("", "Outlook.Application.9").ToString(); key.Close();
int pos = version.LastIndexOf(".");
if (pos >= 0)
{
version = version.Remove(0, pos+1);
return Convert.ToInt32(version);
}
}
}
catch(Exception e)
{
if (key != null) key.Close();
module.DoError(e);
}
return 9;
}
Posted 18 Jul, 2005 16:09:16 Top