I have the code that calls a dll function. The function returns a 4 byte AStr into the variable I pass:
Code: Select all
VarSetCapacity(mystring, 4)
DllCall("some\dllfunction","AStr", mystring, "Cdecl")
(Note that I'm unsure whether I need to set variable size to 8 bytes instead of 4 since I'm using a unicode build, but this doesn't fix the crash)"Unhandled exception at 0x0041BE79 in AutoHotkey.exe: 0xC0000005: Access violation reading location 0x20202036."
However, if I instead make the string directly the DllCall works fine:
Code: Select all
mystring="AAAA"
DllCall("some\dllfunction","AStr", mystring, "Cdecl")
I doubt this is a bug, but I don't understand why VarSetCapacity(mystring, 4) cannot be used with the AStr DllCall and WStr can.