|
找不到什么理论根据,也没什么资料可以参考,依照 WINDOWS 里面已经有的其他 ODBC 驱动,照样子写了一个,经过不少次失败、修改后成功了。想必搞其它驱动也会是这个样子地。 这段子程序的可靠性还有待验证。但是,在程序里自己写(装)驱动,其意义可不光是装装驱动那么简单,它可以使我们的程序更具独立性、灵活性、代码运行起来更加健壮,更主要的有时还可能是一个工程中的关键性技术。分享劳动成果: Private Sub RegODBCDriver(ByVal ODBCDriverName As String, ByVal DllPathAndName As String) Dim r As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine Dim s As Microsoft.Win32.RegistryKey = r.OpenSubKey("SOFTWARE\ODBC\ODBCINST.INI", True) s.CreateSubKey(ODBCDriverName) Dim d As Microsoft.Win32.RegistryKey = s.OpenSubKey(ODBCDriverName, True) d.SetValue("Driver", DllPathAndName) d.SetValue("Setup", DllPathAndName) d.SetValue("APILevel", "1") d.SetValue("SQLLevel", "1") d.SetValue("ConnectFunctions", "Y") Dim f As Microsoft.Win32.RegistryKey = s.OpenSubKey("ODBC Drivers", True) f.SetValue(ODBCDriverName, "Installed") End Sub |