1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
Dim strServer As String * 256
Dim strDatabase As String * 256
Dim Key As String
Dim lngResult As Long
Dim lngRetval As Long
Dim lngLength As Long
Dim lngKey As Long
Dim i As Integer
Dim rstTable As Recordset
Dim rstTable2 As String
Set rstTable = CurrentDb.OpenRecordset("T_DataSource", dbOpenDynaset)
While Not rstTable.EOF
rstTable2 = Nz(rstTable("DataSources"), "")
MsgBox rstTable2
Key = "SOFTWARE\ODBC\ODBC.INI\" & rstTable2
MsgBox Key
lngResult = RegOpenKeyEx(HKEY_CURRENT_USER, Key, ByVal 0&, KEY_QUERY_VALUE, lngKey)
MsgBox lngResult
If lngResult <> ERROR_SUCCESS Then
MsgBox "Impossible d'ouvrir la clé de registre" &
Exit Sub
End If
If lngResult = ERROR_SUCCESS Then
lngLength = 256
' Retrieve the value of the key
lngRetval = RegQueryValueEx( _
lngKey, "Server", 0, 0, ByVal strServer, lngLength)
MsgBox Left(strServer, lngLength)
lngRetval = RegQueryValueEx( _
lngKey, "Database", 0, 0, ByVal strDatabase, lngLength)
MsgBox Left(strDatabase, lngLength)
End If
'
rstTable.MoveNext
Wend |
Partager