Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The DSN entries are stored in the registry in the following keys.</p> <pre>HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources</pre> <p>This contains the list of all defined DSN. This acts as an global index and the specific details for each DSN are stored in a key with the DSN name under:</p> <pre>HKEY_CURRENT_USER\Software\ODBC\ODBC.INI HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI</pre> <p>Create some entries in both User DSN and System DSN tabs from Data Sources (ODBC) control panel applet and check how these values are stored in the registry.</p> <p>The following example enumerate the DSN defined for the user trough Control Panel > Administrative Tools > Data Sources (ODBC) [User Dsn Tab].</p> <p><a href="http://support.microsoft.com/kb/178755" rel="noreferrer">http://support.microsoft.com/kb/178755</a></p> <pre><code> Option Explicit Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _ Alias "RegOpenKeyExA" _ (ByVal hKey As Long, _ ByVal lpSubKey As String, _ ByVal ulOptions As Long, _ ByVal samDesired As Long, phkResult As Long) As Long Private Declare Function RegEnumValue Lib "advapi32.dll" _ Alias "RegEnumValueA" _ (ByVal hKey As Long, _ ByVal dwIndex As Long, _ ByVal lpValueName As String, _ lpcbValueName As Long, _ ByVal lpReserved As Long, _ lpType As Long, _ lpData As Any, _ lpcbData As Long) As Long Private Declare Function RegCloseKey Lib "advapi32.dll" _ (ByVal hKey As Long) As Long Const HKEY_CLASSES_ROOT = &amp;H80000000 Const HKEY_CURRENT_USER = &amp;H80000001 Const HKEY_LOCAL_MACHINE = &amp;H80000002 Const HKEY_USERS = &amp;H80000003 Const ERROR_SUCCESS = 0&amp; Const SYNCHRONIZE = &amp;H100000 Const STANDARD_RIGHTS_READ = &amp;H20000 Const STANDARD_RIGHTS_WRITE = &amp;H20000 Const STANDARD_RIGHTS_EXECUTE = &amp;H20000 Const STANDARD_RIGHTS_REQUIRED = &amp;HF0000 Const STANDARD_RIGHTS_ALL = &amp;H1F0000 Const KEY_QUERY_VALUE = &amp;H1 Const KEY_SET_VALUE = &amp;H2 Const KEY_CREATE_SUB_KEY = &amp;H4 Const KEY_ENUMERATE_SUB_KEYS = &amp;H8 Const KEY_NOTIFY = &amp;H10 Const KEY_CREATE_LINK = &amp;H20 Const KEY_READ = ((STANDARD_RIGHTS_READ Or _ KEY_QUERY_VALUE Or _ KEY_ENUMERATE_SUB_KEYS Or _ KEY_NOTIFY) And _ (Not SYNCHRONIZE)) Const REG_DWORD = 4 Const REG_BINARY = 3 Const REG_SZ = 1 Private Sub Command1_Click() Dim lngKeyHandle As Long Dim lngResult As Long Dim lngCurIdx As Long Dim strValue As String Dim lngValueLen As Long Dim lngData As Long Dim lngDataLen As Long Dim strResult As String lngResult = RegOpenKeyEx(HKEY_CURRENT_USER, _ "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources", _ 0&amp;, _ KEY_READ, _ lngKeyHandle) If lngResult &lt;&gt; ERROR_SUCCESS Then MsgBox "Cannot open key" Exit Sub End If lngCurIdx = 0 Do lngValueLen = 2000 strValue = String(lngValueLen, 0) lngDataLen = 2000 lngResult = RegEnumValue(lngKeyHandle, _ lngCurIdx, _ ByVal strValue, _ lngValueLen, _ 0&amp;, _ REG_DWORD, _ ByVal lngData, _ lngDataLen) lngCurIdx = lngCurIdx + 1 If lngResult = ERROR_SUCCESS Then strResult = strResult &amp; lngCurIdx &amp; ": " &amp; Left(strValue, lngValueLen) &amp; vbCrLf End If Loop While lngResult = ERROR_SUCCESS Call RegCloseKey(lngKeyHandle) Call MsgBox(strResult, vbInformation) End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload