Skip to content

Commit 9fe7221

Browse files
author
maul.esel
committed
add snippet function to get parameter information
1 parent a68d55d commit 9fe7221

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Misc/GetParamInfo.ahk

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
GetParamInfo(elem, method, index)
2+
{
3+
; typeinfo - retrieve expected vt for first param:
4+
local info, hr, arr, vt, td_p, vt_p, href, tkind, refInfo := 0, refName := 0, refAttr := 0, dispid := -1, fnindex := -1, fndesc := 0
5+
static sizeof_ELEMDESC := 4 * A_PtrSize
6+
7+
info := elem[ITL.Properties.TYPE_TYPEINFO] ; retrieve raw pointer
8+
hr := DllCall(NumGet(NumGet(info+0), 10*A_PtrSize, "Ptr"), "Ptr", info, "Str*", method, "UInt", 1, "UInt*", dispid, "Int") ; ITypeInfo::GetIDsOfNames()
9+
MsgBox % "ID: " dispid
10+
11+
hr := DllCall(NumGet(NumGet(info+0), 24*A_PtrSize, "Ptr"), "Ptr", info, "UInt", dispid, "UInt", 1, "UInt*", fnindex, "Int") ; ITypeInfo2::GetFuncIndexOfMemId()
12+
MsgBox % "Index: " fnindex
13+
14+
hr := DllCall(NumGet(NumGet(info+0), 05*A_PtrSize, "Ptr"), "Ptr", info, "UInt", fnindex, "Ptr*", fndesc, "Int") ; ITypeInfo::GetFuncDesc()
15+
MsgBox % "FNDESC: " fndesc
16+
17+
arr := NumGet(1*fndesc, 04 + 1*A_PtrSize, "Ptr") ; FUNCDESC::lprgelemdescParam
18+
MsgBox % "ARR: " arr
19+
20+
vt := NumGet(1*arr, (index - 1) * sizeof_ELEMDESC + A_PtrSize, "UShort") ; FUNCDESC::lprgelemdescParam[0]::tdesc::vt
21+
MsgBox % "VT: " vt
22+
23+
if (vt == 26)
24+
{
25+
td_p := NumGet(1*arr, (index - 1) * sizeof_ELEMDESC + 00, "Ptr")
26+
vt_p := NumGet(1*td_p, A_PtrSize, "UShort")
27+
MsgBox % "VT - p: " vt_p
28+
}
29+
else if (vt == 29)
30+
{
31+
href := NumGet(1*arr, 00, "UInt")
32+
hr := DllCall(NumGet(NumGet(info+0), 14*A_PtrSize, "Ptr"), "Ptr", info, "UInt", href, "Ptr*", refInfo, "Int")
33+
hr := DllCall(NumGet(NumGet(refInfo+0), 03*A_PtrSize, "Ptr"), "Ptr", refInfo, "Ptr*", refAttr, "Int")
34+
tkind := NumGet(1*refAttr, 36+A_PtrSize, "UInt")
35+
hr := DllCall(NumGet(NumGet(refInfo+0), 12*A_PtrSize, "Ptr"), "Ptr", refInfo, "Int", -1, "Ptr*", refName, "Ptr", 0, "Ptr", 0, "Ptr", 0, "Int")
36+
37+
MsgBox % "TYPEKIND: " tkind " [ " StrGet(refName) " ]"
38+
}
39+
40+
DllCall(NumGet(NumGet(info+0), 20*A_PtrSize, "Ptr"), "Ptr", info, "Ptr", fndesc) ; ITypeInfo::ReleaseFuncDesc()
41+
}

Misc/test.ahk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
SetBatchLines -1
66
ListLines Off
77

8+
#include GetParamInfo.ahk
89
#include ..\
910
#include Main.ahk
1011

0 commit comments

Comments
 (0)