Jump to content

List installed COM Objects (_GetCOMObjectControls)


funkey
 Share

Recommended Posts

Here I have an older function of mine to find and list installed ActiveX controls, so you can use some of them to show in your Gui.

#include <Array.au3>

Local $aCOMObjects = _GetCOMObjectControls()
_ArrayDisplay($aCOMObjects, "All")

$aCOMObjects = _GetCOMObjectControls("Control")
_ArrayDisplay($aCOMObjects, "Control")

GUICreate("COM-Test", 620, 500)
Local $oFileSearch = ObjCreate("CompatUI.SelectFile.1")
Local $oPivot = ObjCreate("OWC11.PivotTable.11")

If IsObj($oFileSearch) Then GUICtrlCreateObj($oFileSearch, 10, 10, 600, 25)
If IsObj($oPivot) Then
    GUICtrlCreateObj($oPivot, 10, 100, 600, 383)

;~  $oPivot.ConnectionString =  "Provider=MSDASQL.1;Persist Security Info=True;" & _
;~                              "Extended Properties=\'DSN=MS Access Database;" & _
;~                              "DBQ=" & @ScriptDir & "test.mdb;\;" & _
;~                              "Initial Catalog=" & @ScriptDir & "\test"
;~  $oPivot.DisplayToolbar = True

EndIf


GUISetState()

Do
    Sleep(10)
Until GUIGetMsg() = -3

Func _GetCOMObjectControls($sFilter = "")
    ;funkey
    Local $objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
    Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ClassicCOMClassSetting where Control = True AND ProgId Like '%" & $sFilter & "%'", "WQL", 48)
    If Not IsObj($colItems) Then Return SetError(1, 0, "")
    Local $sRet
    For $objItem In $colItems
        $sRet &= $objItem.ProgId & @TAB
        $sRet &= $objItem.Caption & @CR
    Next
    Local $aTemp = StringSplit($sRet, @CR, 2)
    If @error Then Return SetError(1)
    Local $aRet[UBound($aTemp) - 1][2]
    For $i = 0 To UBound($aTemp) - 2
        $aRet[$i][0] = StringLeft($aTemp[$i], StringInStr($aTemp[$i], @TAB, 0, -1) - 1)
        $aRet[$i][1] = StringTrimLeft($aTemp[$i], StringInStr($aTemp[$i], @TAB, 0, -1))
    Next
    Return $aRet
EndFunc   ;==>_GetCOMObjectControls

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Could be useful sometime, thanks for sharing. I added an array sort which makes the overview much easier.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...