Difference between revisions of "ADO Tools"

From AutoIt Wiki
Jump to navigation Jump to search
m (List all installed OLE DB providers)
m (List all installed OLE DB providers)
Line 1: Line 1:
 
= List all installed OLE DB providers =
 
= List all installed OLE DB providers =
 +
This tool lists all available providers installed on the computer. You get the registry key, the name of the provider (as to be used in the connection string) plus a description of the provider.
 +
 
Idea taken from http://www.motobit.com/help/RegEdit/sa117.htm
 
Idea taken from http://www.motobit.com/help/RegEdit/sa117.htm
 
<syntaxhighlight lang="autoit">
 
<syntaxhighlight lang="autoit">

Revision as of 10:40, 17 January 2014

List all installed OLE DB providers

This tool lists all available providers installed on the computer. You get the registry key, the name of the provider (as to be used in the connection string) plus a description of the provider.

Idea taken from http://www.motobit.com/help/RegEdit/sa117.htm

#include <Constants.au3>
#include <Array.au3>
Global $sOutput, $oRegistry, $oKey, $sKey = "HKCR\CLSID", $iIndexReg = 1, $iIndexResult = 0
Global $aResult[200][3], $sTitle = "OLE DB Providers", $iMax = 100000, $iMin = 1, $iPrevious = $iMin, $iCurrent = $iMax/2, $iTemp
ProgressOn($sTitle, "Processing the Registry", "", Default, Default, $DLG_MOVEABLE)
; Count the number of keys
While 1
    RegEnumKey($sKey, $iCurrent)
    If @error = -1 Then ; Requested subkey (key instance) out of range
        $iMax = $iCurrent
        $iCurrent = Int(($iMin + $iMax) / 2)
        $iPrevious = $iMax
    Else
        If $iPrevious <= ($iCurrent + 1) And $iPrevious >= ($iCurrent - 1) Then ExitLoop
        $iMin = $iCurrent
        $iCurrent = Int(($iMin + $iMax) / 2)
        $iPrevious = $iMin
    EndIf
WEnd
; Process registry
While 1
    If Mod($iIndexReg, 10) = 0 Then
        $iPercent = Int($iIndexReg * 100 / $iCurrent)
        ProgressSet($iPercent, $iIndexReg & " keys of " & $iCurrent & " processed (" & $iPercent & "%)")
    EndIf
    $sSubKey = RegEnumKey($sKey, $iIndexReg)
    If @error Then ExitLoop
    $sKeyValue = RegRead($sKey & "\" & $sSubKey, "OLEDB_SERVICES")
    If @error = 0 Then
        $aResult[$iIndexResult][0] = $sKey & "\" & $sSubKey
        $aResult[$iIndexResult][1] = RegRead($sKey & "\" & $sSubKey, "")
        $aResult[$iIndexResult][2] = RegRead($sKey & "\" & $sSubKey & "\OLE DB Provider", "")
        $iIndexResult = $iIndexResult + 1
    EndIf
    $iIndexReg = $iIndexReg + 1
WEnd
ProgressOff()
ReDim $aResult[$iIndexResult][3]
_ArrayDisplay($aResult, $sTitle, "", 0, Default, "Registry key|OLE DB Provider|Description")

Result:

OLE DB Providers