Click here to Skip to main content
15,886,873 members
Articles / Programming Languages / C#
Tip/Trick

Programmatically check Access Database Engine for MS Office (2007 or 2010) installed on a client system

Rate me:
Please Sign up or sign in to vote.
4.90/5 (3 votes)
14 Mar 2013CPOL 33.4K   6   3
C# code to determine the installation of Access database engine in a client system.

Introduction

This tip gives C# code to determine the installation of the Access database engine in a client system.

Background 

But after I uninstall Access database engine the file ACECORE.DLL for Office 2010 is still in the same path, thus my purpose is failed. After some investigation on my system I found the piece of code shown below which would help in determining the installation of the "Access Database Engine".

This piece of code will be helpful for those who have just started in C#, like me :-)

Using the code

C#
string AccessDBAsValue = string.Empty;
RegistryKey rkACDBKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Classes\Installer\Products");
if (rkACDBKey != null)
{ 
    //int lnSubKeyCount = 0;
    //lnSubKeyCount =rkACDBKey.SubKeyCount; 
    foreach(string subKeyName in rkACDBKey.GetSubKeyNames())
    {
        using (RegistryKey RegSubKey = rkACDBKey.OpenSubKey(subKeyName))
        {
            foreach (string valueName in RegSubKey.GetValueNames())
            {
                if (valueName.ToUpper() == "PRODUCTNAME")
                {
                    AccessDBAsValue = (string)RegSubKey.GetValue(valueName.ToUpper());
                    if (AccessDBAsValue.Contains("Access database engine"))
                    {
                        llretval = true;
                        break;
                    }
                }
            }
        }
        if (llretval)
        {
            break;
        }
    }

Points to Note

Please note that if the Access Database Engine is installed on an XP 32 bit system, the value will be "Microsoft Office Access database engine 2007" in the Registry key. For Office 2010 on a Win7 32 bit system it will be "Microsoft Access database engine 2010" [I did not yet try other versions], so there is a little difference in these values.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) CT Space
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionThank you Pin
evry1falls19-Apr-20 10:28
evry1falls19-Apr-20 10:28 
QuestionThanks man!! Pin
Tejas Vaishnav11-Nov-14 19:27
professionalTejas Vaishnav11-Nov-14 19:27 
I am searching this type of code, to create my custom bootstrapped for Microsoft ms access database driver, and your code is really help me to create component checker. Thanks Smile | :)
Tejas Vaishnav
Find me on Facebook | Blog

PraiseRe: Thanks man!! Pin
evry1falls14-Apr-22 15:41
evry1falls14-Apr-22 15:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.