Jump to content

Recommended Posts

Posted (edited)

dllstructsetdata($struct,1,"EF",2)       ;should cause an error imho because you want to set a 2-byte "String" into a 1-byte "char" but autoit writes tacitly (my dictionary says this is the right word^^) only the first byte of your string with the result that the struct is now "AECD"....

I'm sure it's causing an error on some level, but it's dealt with before it reaches us. Lucky us, I say.

This can always be done (I see it was suggested already, but nevermind):

$tMAINStructure = DllStructCreate("char[20]")
DllStructSetData($tMAINStructure, 1, "Infinitive particle")

ConsoleWrite("Before = ")
ConsoleWrite(DllStructGetData($tMAINStructure, 1) & @CRLF)


$tSUBstructure = DllStructCreate("char[12]", DllStructGetPtr($tMAINStructure) + 7) ; after seventh
DllStructSetData($tSUBstructure, 1, "e number")

ConsoleWrite("After = ")
ConsoleWrite(DllStructGetData($tMAINStructure, 1) & @CRLF)
Edited by trancexx

♡♡♡

.

eMyvnE

Posted

This is a documentation error. The documentation claims that the index defaults to 1 when not specified. This is wrong. AutoIt defaults to writing as much of the source string into as much of the destination buffer as it can. That's why these two lines behave differently:

Local $a=DllStructCreate('byte[4]')

DllStructSetData($a,1,Binary('0xAABB'), 1)  ; Writes only 0xAA because it was explicitly told to write to index 1.
ConsoleWrite(DllStructGetData($a, 1) & @CRLF)

DllStructSetData($a,1,Binary('0xAABB')) ; Writes the entire string.
ConsoleWrite(DllStructGetData($a, 1) & @CRLF)

I will correct the documentation to describe the actual behavior.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...