Returns the current memory address of a string.
Address := StrPtr(Value)
Type: String
Type: Integer or StringBuffer
If Value is a variable, this function returns a StringBuffer entangled with that variable. Otherwise, it returns the address of a pinned UTF-16 copy of the string.
Strings are immutable managed objects, so StrPtr does not expose a variable's internal string storage.
Ptr := StrPtr(MyVar)
The returned StringBuffer can be passed directly as a pointer to DllCall, NumPut and similar functions. After such a call writes to it, the original variable is updated from the buffer. For new code, creating a StringBuffer explicitly is clearer and is recommended.
Ptr := StrPtr("literal string")
For a literal or other non-variable value, the returned integer points to a pinned copy. Do not modify a literal string through this pointer. Release the pin with ObjFree when it is no longer needed; otherwise it remains allocated until script shutdown.
StringBuffer, ObjFree, DllCall, SendMessage, Buffer object, NumPut, NumGet