Core Function DllStructGetPtr
From Sputnik Wiki
DllStructGetPtr( <dllstruct>, <element>, <index> )
Contents |
Description
Returns the pointer to the struct or an element in the struct or even a specific index of an array object within an elment.
Parameters
dllstruct
The struct returned by DLLStructCreate.
element
Optional; The element of the struct who's pointer you need by using its element name as defifined in DLLStructCreate.
index
Optional; The array index value of an element in the struct for example the 46th index of char a[500] array.
Return Value
Success: The pointer to the struct or element or elements element.
Failure: @PTRZero.
Remarks
Used in DLLCall.
Example
/*========================================================= Create the struct struct { int var1; unsigned char var2; unsigned int var3; char var4[128]; } =========================================================*/ $str = "int var1;ubyte var2;uint var3;char var4[128]"; $a = DllStructCreate($str); if ( !$a ) { MsgBox("Error in DllStructCreate"); exit(); } /*========================================================= Set data in the struct struct.var1 = -1; struct.var2 = 255; struct.var3 = 777; strcpy(struct.var4,"Hello"); struct.var4[0] = 'h'; =========================================================*/ DllStructSetData($a,"var1",-1); DllStructSetData($a,"var2",255); DllStructSetData($a,"var3",777); DllStructSetData($a,"var4","Hello"); DllStructSetData($a,"var4","G",0); /*========================================================= Display info in the struct ;=========================================================*/ MsgBox("Struct Size: " . DllStructGetSize($a) . @CRLF . "Struct pointer: " . DllStructGetPtr($a) . @CRLF . "Data:" . @CRLF . DllStructGetData($a,"var1") . @CRLF . DllStructGetData($a,"var2") . @CRLF . DllStructGetData($a,"var3") . @CRLF . DllStructGetData($a,"var4"), "DllStruct");