COM Array - Byref Output (a122)

Get help for the alpha version of AutoHotkey v2 here. Please state the v2 version you are working with in the title when making a new topic.
Posts: 7
Joined: 16 Nov 2020, 14:47
GitHub: CptRootBeard

COM Array - Byref Output (a122)

17 Nov 2020, 14:56

**Using a122
I've had a similar issue recently with byref outputs and scintilla messages, and I'm sure it's because I don't totally grasp the memory operations taking place.
I'm using COM to interact with AutoCAD, and I've been able to send values through COM to CAD no problem. Output from CAD->AHK has been another story. I need to use the following method to retrieve an entity's XData (VBA signature shown):

Code: Select all

object.GetXData AppName, XDataType, XDataValue
Where AppName is an input string, XDataType is an output array of shorts, and XDataValue is an output array of variants.

I've tried this (among several other variations):

To the following results:

I know this specific case isn't easily testable, as it requires AutoCAD. I'm hoping my mistake will be glaringly obvious to someone with a little more COM knowledge than myself.
Link to the AutoCAD API:
http /view/OARX/2019/ENU/?guid=GUID-330FCA31-A2A9-47F0-972D-6915B6B98426

Pages with examples that I've tried to adapt to my use:
https /v2/docs/commands/ComObject.htm#ExByRef
https /v2/docs/commands/ComObjArray.htm

The VT Enum Class I'm using:
Posts: 7
Joined: 16 Nov 2020, 14:47
GitHub: CptRootBeard

Re: COM Array - Byref Output (a122)

20 Nov 2020, 09:21

More generally, here's where I could use guidance:

I need a safearray of a given type of data (e.g. VT_VARIANT or VT_I2).
This has to be passed to a COM object's method byref to be used as an output -> I need a pointer (in a COM acceptable form) to the safearray.
I've seen the examples that call BufferAlloc() to create a buffer of appropriate size, then wrap the buffer.ptr in a ComObject(VT_BYREF|etc.) call before passing it to the method.
My data type or buffer size is probably incorrect, so I'm not having any luck.

In short:
1. How much memory do I buffer for an array? Perhaps (# of entries)*(bytes per entry)?
2. Would COMObject(VT_BYREF|VT_ARRAY|VT_VARIANT, buff.ptr) denote a reference to an array of variants? If not, what is the appropriate type here?

Any help is much appreciated.

Return to “AutoHotkey v2 Help”

Who is online

Users browsing this forum: No registered users and 1 guest