Open sancarn opened 7 years ago
;Get ICollection from returned object (oRet)
ICollection := ComObject(ComObjType(oRet), ComObjQuery(oRet, "{DE8DB6F8-D101-3A92-8D1C-E72E5F10E992}"), 1)
;Get IList from ICollection
IList := ComObject(9, ComObjQuery(ICollection, "{7BCFA00F-F764-3113-9140-3BBD127A96BB}"), 1)
;Loop over the list and append them to an array
ret := []
Loop % ICollection.Count()
ret.push(IList.Item(A_Index - 1))
With the addition of findIID() function
this becomes a lot easier to manage (at the cost of speed):
getList(oRet){
;Get ICollection from returned object (oRet)
ICollection := ComObject(ComObjType(oRet), ComObjQuery(oRet, findIID("ICollection")), 1)
;Get IList from ICollection
IList := ComObject(9, ComObjQuery(ICollection, findIID("IList")), 1)
;Loop over the list and append them to an array
ret := []
Loop % ICollection.Count()
ret.push(IList.Item(A_Index - 1))
return ret
}
findIID(name){
Loop, Reg, HKEY_CLASSES_ROOT\Interface\, KV
{
RegRead, interface, HKEY_CLASSES_ROOT\Interface\%A_LoopRegName%
if (interface = name)
return A_LoopRegName
}
}
Other IIDs:
Collection_Generic_Dictionary = {F31091E6-B0A8-11D6-B6FC-005056C00008}
IDispatch = {00020400-0000-0000-C000-000000000046}
IUnknown ={00000000-0000-0000-C000-000000000046}
If a VB Collection is created, e.g. a VB List:
How do we parse the List in AHK?