如何检查系统上是否安装了OLEDB驱动程序?
如何确保在启动应用程序时安装了特定的 OLEDB 驱动程序? 我使用 Delphi 中的 ADO,并且希望在缺少驱动程序时显示描述性错误消息。 从 ADO 返回的错误并不总是那么用户友好。
可能有一个不错的小函数可以返回所有已安装的驱动程序,但我还没有找到它。
How can I make sure that a certain OLEDB driver is installed when I start my application? I use ADO from Delphi and would like to display a descriptive error message if the driver is missing. The error that's returned from ADO isn't always that user-friendly.
There are probably a nice little function that returns all installed drivers but I haven't found it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以获取 ADO 提供程序名称并在注册表中的路径 HKEY_CLASSES_ROOT\[Provider_Name] 中检查它。
You can get a ADO provider name and check it in registry at path HKEY_CLASSES_ROOT\[Provider_Name].
最简单的方法难道不是在启动时尝试建立连接并捕获错误吗?
我的意思是,您可能会收到一些不同的错误,例如,取决于用户是否在线,但您应该能够测试这些情况。
Wouldn't the easiest way just be trying to make a connection at start-up and catching the error?
I mean you might get a few different errors back depending on, for example, the user is online, but they're cases that you should be able to test for.
我相信有问题的 OLEDB 对象埋藏在注册表中的某个位置,因为 OLEDB / ADO 是 COM 解决方案。 我的猜测是看看您是否可以在注册表中找到安装驱动程序的 GUID。
I believe the OLEDB objects in question are buried someplace in the registry, since OLEDB / ADO is a COM solution. My guess would be to see if you can find the GUID that your driver is installed as in the registry.
每个提供程序都有一个与其类关联的 GUID。 要查找 GUID,请打开 regedit 并在注册表中搜索提供程序名称。 例如,搜索“Microsoft Jet 4.0 OLE DB 提供程序”。 找到它后,复制该密钥(GUID 值)并在应用程序的注册表搜索中使用它。
Each provider has a GUID associated with its class. To find the guid, open regedit and search the registry for the provider name. For example, search for "Microsoft Jet 4.0 OLE DB Provider". When you find it, copy the key (the GUID value) and use that in a registry search in your application.
这是一个老问题,但我现在遇到了同样的问题,也许这可以帮助其他人。
在 Delphi 7 中,ADODB 中有一个过程返回带有提供程序名称的 TStringList。
使用示例:
This is an old question but I had the same problem now and maybe this can help others.
In Delphi 7 there is an procedure in ADODB that return a TStringList with the provider names.
Usage example: