确定对象的类名
; 示例: 确定对象的类名. obj := ComObjCreate("Scripting.Dictionary") MsgBox % "Interface name: " ComObjType(obj, "name") IID_IProvideClassInfo := "{B196B283-BAB4-101A-B69C-00AA00341D07}" ; 请求到对象的 IProvideClassInfo 接口的指针. if !(pci := ComObjQuery(obj, IID_IProvideClassInfo)) { MsgBox IProvideClassInfo interface not supported. return } ; 调用 GetClassInfo 来获取到 ITypeInfo 接口的指针. DllCall(vtable(pci, 3), "ptr", pci, "ptr*", ti) ; 调用 GetDocumentation 来获取对象的完整类型名称. DllCall(vtable(ti, 12), "ptr", ti, "int", -1, "ptr*", name, "ptr", 0, "ptr", 0, "ptr", 0) ; 转换 BSTR 指针为可用的字符串. name := StrGet(name, "UTF-16") ; 释放原始接口指针. ObjRelease(ti) ObjRelease(pci) ; 显示类型名称! MsgBox % "Class name: " name vtable(ptr, n) { ; NumGet(ptr+0) 返回对象的虚函数表 ; (简称为 vtable) 的地址. 表达式的其余部分从 ; vtable 获取第 n 个函数的地址. return NumGet(NumGet(ptr+0), n*A_PtrSize) }