After some thinking, StrLen
doesnt calculate string size on the spot but just retrieves its field size which was previously saved by AHK internally. So it works in case it was a real string or was properly initiated with VarSetCapacity
for binary fields by the caller. But once we skip ByRef
keyword for this argument, AHK will try to copy that "string" field to a function's local var with the same name (shadowed) and prematurely cut it at first zero token. Correct me if Im wrong.
In the OP example its a string not a real binary data to be converted so everything works as expected.
Helgef wrote: ↑
23 Jan 2019, 08:14
No, you call varsetcapacity(var), as documented. The length of the buffer is stored internally.
Btw main question is how to retrieve it back.
ofc, a correct way for binary fields would be to use its counterpart VarGetCapacity
but... hey there is no such a function for regular vars. Its analogue exists for object's fields only... object.GetCapacity("field_name")