开发者

How to determine if VFPOLEDB provider is installed/registered?

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#?


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;
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜