FireFox Posted August 2, 2013 Posted August 2, 2013 (edited) Hi,I don't understand how the size of the structure works. I know that an int has a size of 4 bytes, if I get the size of the struct then I have 4 bytes;a byte has as size of 1 byte, if I get the size of the struct then I have 1 byte. Until here everything seems fine, unless I make a structure with the two elements, the size is 8 bytes; 4+1=5 and not 8. Here is the example :#include <Constants.au3> Local Const $tagSTRUCT1 = "struct;int var1;endstruct" Local $tSTRUCT1 = DllStructCreate($tagSTRUCT1) MsgBox($MB_SYSTEMMODAL, "", "Struct1 Size: " & DllStructGetSize($tSTRUCT1)) Local Const $tagSTRUCT2 = "struct;byte var2;endstruct" Local $tSTRUCT2 = DllStructCreate($tagSTRUCT2) MsgBox($MB_SYSTEMMODAL, "", "Struct2 Size: " & DllStructGetSize($tSTRUCT2)) Local Const $tagSTRUCT3 = "struct;int var1;byte var2;endstruct" Local $tSTRUCT3 = DllStructCreate($tagSTRUCT3) MsgBox($MB_SYSTEMMODAL, "", "Struct3 Size: " & DllStructGetSize($tSTRUCT3))Thanks for anyhelp Br, FireFox. Edited August 2, 2013 by FireFox
Solution stormbreaker Posted August 2, 2013 Solution Posted August 2, 2013 (edited) Firefox, we need to use align here. Read help file for DllStructCreate() function FROM help file: DllStructCreate("short;int") ; structure is 8 bytes, the "int" is at offset 4 DllStructCreate("align 2;short;int") ; structure is 6 bytes, the "int" is at offset 2 Regards, MKISH Edited August 2, 2013 by MKISH ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1
FireFox Posted August 2, 2013 Author Posted August 2, 2013 I already read the helpfile ofc, I just didn't understand how it worked. Had to have a little break to get it. Thank you.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now