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#?
A:
As suggested here: http://stackoverflow.com/questions/113860/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;
}
}
Cosmin Prund
2010-07-02 09:05:37