How to check if an OLEDB driver is installed on the system?

前端 未结 6 1988
走了就别回头了
走了就别回头了 2020-12-06 16:59

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

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-06 17:05

    namespace Common {
      public class CLSIDHelper {
    
      [DllImport("ole32.dll")]
      static extern int CLSIDFromProgID([MarshalAs(UnmanagedType.LPWStr)] string lpszProgID, out Guid pclsid);
    
    
      public static Guid RetrieveGUID(string Provider) {
        Guid CLSID = Guid.Empty;
        int Ok = CLSIDFromProgID(Provider, out CLSID);
        if (Ok == 0)
           return CLSID;
        return null;
      }
     }
    }
    

提交回复
热议问题