[2.0-a129-78d2aa15] ComCall in documentation example fails

Report problems with documented functionality
iPhilip
Posts: 819
Joined: 02 Oct 2013, 12:21

[2.0-a129-78d2aa15] ComCall in documentation example fails

16 Mar 2021, 11:24

When running the following script from the ComObjQuery documentation page, the second ComCall fails and reports "Parameter #2 of ComCall is invalid."

Code: Select all

obj := ComObjCreate("Scripting.Dictionary")

MsgBox "Interface name: " ComObjType(obj, "name")

IID_IProvideClassInfo := "{B196B283-BAB4-101A-B69C-00AA00341D07}"

; Request the object's IProvideClassInfo interface.
try
    pci := ComObjQuery(obj, IID_IProvideClassInfo)
catch
{
    MsgBox "IProvideClassInfo interface not supported."
    return
}

; Call GetClassInfo to retrieve a pointer to the ITypeInfo interface.
ComCall(3, pci, "ptr*", ti := 0)

; Wrap ti to ensure automatic cleanup.
ti := ComObject(13, ti)

; Call GetDocumentation to get the object's full type name.
ComCall(12, ti, "int", -1, "ptr*", pname := 0, "ptr", 0, "ptr", 0, "ptr", 0)  ; Parameter #2 of ComCall is invalid.

; Convert the BSTR pointer to a usable string.
name := StrGet(pname, "UTF-16")

; Clean up.
DllCall("oleaut32\SysFreeString", "ptr", pname)
pci := ti := ""

; Display the type name!
MsgBox "Class name: " name
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: [2.0-a129-78d2aa15] ComCall in documentation example fails

16 Mar 2021, 17:49

Pname must be prefixed with & since the * suffix was used.
iPhilip
Posts: 819
Joined: 02 Oct 2013, 12:21

Re: [2.0-a129-78d2aa15] ComCall in documentation example fails

16 Mar 2021, 18:11

@kczx3, Thank you for catching that. Not only does pname needs to be prefixed but ti as well. I will post an updated version in the "Suggestions on documentation improvements" forum.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: [2.0-a129-78d2aa15] ComCall in documentation example fails

16 Mar 2021, 19:42

Ah yes, in the first ComCall. 👍🏻
iPhilip
Posts: 819
Joined: 02 Oct 2013, 12:21

Re: [2.0-a129-78d2aa15] ComCall in documentation example fails

16 Mar 2021, 20:33

Thank you, @swagfag.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 42 guests