ADO Tools: Difference between revisions

From AutoIt Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 1: Line 1:
= List all installed OLE DB providers =
= List all installed OLE DB providers =
<syntaxhighlight lang="autoit">
<syntaxhighlight lang="autoit">
#include <Constants.au3>
#include <Array.au3>
#include <Array.au3>
Global $sOutput, $oRegistry, $oKey, $sKey = "HKCR\CLSID", $iIndexReg = 1, $iIndexResult = 0
Global $sOutput, $oRegistry, $oKey, $sKey = "HKCR\CLSID", $iIndexReg = 1, $iIndexResult = 0
Global $aResult[200][3]
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
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)
     $sSubKey = RegEnumKey($sKey, $iIndexReg)
     If @error Then ExitLoop
     If @error Then ExitLoop
Line 16: Line 37:
     $iIndexReg = $iIndexReg + 1
     $iIndexReg = $iIndexReg + 1
WEnd
WEnd
ProgressOff()
ReDim $aResult[$iIndexResult][3]
ReDim $aResult[$iIndexResult][3]
_ArrayDisplay($aResult, "OLE DB Providers", "", 0, Default, "Registry key|OLE DB Provider|Description")
_ArrayDisplay($aResult, $sTitle, "", 0, Default, "Registry key|OLE DB Provider|Description")
 
</syntaxhighlight>
</syntaxhighlight>



Revision as of 15:59, 9 January 2014

List all installed OLE DB providers

#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