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

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

推荐答案

skamradt是正确的。每个提供者都有与其类相关联的GUID。要查找guid,请打开regedit并在注册表中搜索提供程序名称。例如,搜索Microsoft Jet 4.0 OLE DB提供程序。找到它时,复制密钥(GUID值),并将其用于应用程序中的注册表搜索。

skamradt is correct. 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( '\SOFTWARE\Classes\CLSID\{C1637B2F-CA37-11D2-AE5C-00609791DC73}' );
  finally
    reg.Free;
  end;
end;

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

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