Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine if VFPOLEDB provider is installed/registered?

Tags:

c#

oledb

provider

I need to check in my program if the VFPOLEDB provider is installed/registered? I want to show a message and tell the user to download and install the provider. How do I check it in C#?

like image 295
John Sheares Avatar asked Mar 22 '10 06:03

John Sheares


1 Answers

As suggested here: How to check if an OLEDB driver is installed on the system? you can look for VFPOLEDB's key in the Registry. Open up regedit and search for VFPOLEDB, you'll find it in several places; You're interested in the one over here:

HKEY_CLASSES_ROOT\TypeLib\{50BAEECA-ED25-11D2-B97B-000000000000}\1.0\0\win32

So we know VFPOLEDB should be registered over here:

HKEY_CLASSES_ROOT\TypeLib\{50BAEECA-ED25-11D2-B97B-000000000000}

We can test if it's there using this C# expression:

(Registry.ClassesRoot.OpenSubKey("TypeLib\\{50BAEECA-ED25-11D2-B97B-000000000000}") != null)

Or we can wrap it up in a nice static class for easy reuse:

public static class CheckVfpOleDb
{
    public static bool IsInstalled()
    {
        return Registry.ClassesRoot.OpenSubKey("TypeLib\\{50BAEECA-ED25-11D2-B97B-000000000000}") != null;
    }
}
like image 146
Cosmin Prund Avatar answered Nov 05 '22 00:11

Cosmin Prund