如何检查系统上是否安装了 OLEDB 驱动程序? [英] How to check if an OLEDB driver is installed on the system?

查看:40
本文介绍了如何检查系统上是否安装了 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.

推荐答案

每个提供程序都有一个与其类相关联的 GUID.要查找 guid,请打开 regedit 并在注册表中搜索提供程序名称.例如,搜索Microsoft Jet 4.0 OLE DB Provider".找到后,复制密钥(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.

function OleDBExists : boolean;
var
  reg : TRegistry;
begin
  Result := false;

  // See if Advantage OLE DB Provider is on this PC
  reg := TRegistry.Create;
  try
    reg.RootKey := HKEY_LOCAL_MACHINE;
    Result := reg.OpenKeyReadOnly( 'SOFTWAREClassesCLSID{C1637B2F-CA37-11D2-AE5C-00609791DC73}' );
  finally
    reg.Free;
  end;
end;

这篇关于如何检查系统上是否安装了 OLEDB 驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆