Code: Select all
#NoEnv
F3::
obj := ComObjCreate("Scripting.Dictionary")
IID_IProvideClassInfo := "{B196B283-BAB4-101A-B69C-00AA00341D07}"
; Request a pointer to the object's IProvideClassInfo interface.
if !(pci := ComObjQuery(obj, IID_IProvideClassInfo))
{
MsgBox IProvideClassInfo interface not supported.
return
}
Loop
{
; Call GetClassInfo to retrieve a pointer to the ITypeInfo interface.
DllCall(vtable(pci, 3), "ptr", pci, "ptr*", ti)
; Call GetDocumentation to get the object's full type name.
DllCall(vtable(ti, 12), "ptr", ti, "int", -1, "ptr*", name, "ptr", 0, "ptr", 0, "ptr", 0)
; Convert the BSTR pointer to a usable string.
name := StrGet(name, "UTF-16")
; Release raw interface pointers.
ObjRelease(ti)
}
ObjRelease(pci)
; Display the type name!
MsgBox % "Class name: " name
Esc::ExitApp
vtable(ptr, n) {
; NumGet(ptr+0) returns the address of the object's virtual function
; table (vtable for short). The remainder of the expression retrieves
; the address of the nth function's address from the vtable.
return NumGet(NumGet(ptr+0), n*A_PtrSize)
}
Code: Select all
obj := ComObjCreate("Scripting.Dictionary")
MsgBox % "Interface name: " ComObjType(obj, "name")
IID_IProvideClassInfo := "{B196B283-BAB4-101A-B69C-00AA00341D07}"
; Request a pointer to the object's IProvideClassInfo interface.
if !(pci := ComObjQuery(obj, IID_IProvideClassInfo))
{
MsgBox IProvideClassInfo interface not supported.
return
}
; Call GetClassInfo to retrieve a pointer to the ITypeInfo interface.
DllCall(vtable(pci, 3), "ptr", pci, "ptr*", ti)
; Call GetDocumentation to get the object's full type name.
DllCall(vtable(ti, 12), "ptr", ti, "int", -1, "ptr*", pname, "ptr", 0, "ptr", 0, "ptr", 0)
; Convert the BSTR pointer to a usable string.
name := StrGet(pname, "UTF-16")
; Free the BSTR referenced by pname
DllCall("OleAut32\SysFreeString", "ptr", pname)
; Release raw interface pointers.
ObjRelease(ti)
ObjRelease(pci)
; Display the type name!
MsgBox % "Class name: " name
vtable(ptr, n) {
; NumGet(ptr+0) returns the address of the object's virtual function
; table (vtable for short). The remainder of the expression retrieves
; the address of the nth function's address from the vtable.
return NumGet(NumGet(ptr+0), n*A_PtrSize)
}
- iPhilip
P.S.: This is a reposting of this post.