[v2] Example #1 in the ComObjQuery page Topic is solved

Share your ideas as to how the documentation can be improved.
iPhilip
Posts: 815
Joined: 02 Oct 2013, 12:21

[v2] Example #1 in the ComObjQuery page

Post by iPhilip » 16 Mar 2021, 18:19

Example #1 in the ComObjQuery documentation page should be changed as follows (look for the <--- mark):

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)  ; <--- changed ti to &ti

; 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.  <--- changed pname to &pname

; 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)

iPhilip
Posts: 815
Joined: 02 Oct 2013, 12:21

Re: [v2] Example #1 in the ComObjQuery page

Post by iPhilip » 16 Mar 2021, 20:35

Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

User avatar
Ragnar
Posts: 613
Joined: 30 Sep 2013, 15:25

Re: [v2] Example #1 in the ComObjQuery page  Topic is solved

Post by Ragnar » 17 Mar 2021, 09:24

Thanks for reporting. The changes are included in PR #473. Note that ComObjQuery.htm#L109 and WinSetRegion.htm#L72-L77 are still functional without &.

iPhilip
Posts: 815
Joined: 02 Oct 2013, 12:21

Re: [v2] Example #1 in the ComObjQuery page

Post by iPhilip » 17 Mar 2021, 10:31

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

Post Reply

Return to “Suggestions on Documentation Improvements”