这段子程序的可靠性还有待验证。但是,在程序里自己写(装)驱动,其意义可不光是装装驱动那么简单。
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("SOFTWAREODBCODBCINST.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
责任编辑:小草