# Function Reference

DllStructGetData

Returns the data of an element of the struct.

DllStructGetData ( Struct, Element [, index ] )

Parameters

Struct | The struct returned by DllStructCreate.
Element | Which element of the struct you want to access, starting at 1.
index | *If the element is an array, you need to specify which index to return, otherwise it returns index 1.

*char[n], byte[n] and ubyte[n] return all element data when index is omitted.

Return Value

Success: | Data in the element of the struct.
Failure: | 0.
@Error: | 0 = No Error.
| 1 = Struct not a correct struct returned by DllStructCreate.
| 2 = Element value out of range.
| 3 = index would be outside of the struct.
| 4 = Element data type is unknown
| 5 = index < 0.

Remarks

When the element is char[n] and index is omitted the data returned is a String,
when the element is byte[n] or ubyte[n] and index is omitted the data returned is a BinaryString,
otherwise it always returns a number.

Related

DllCall, DllStructCreate, DllStructSetData

Example

#cs
From MSDN:
typedef struct _OSVERSIONINFO
{
DWORD dwOSVersionInfoSize; //1
DWORD dwMajorVersion; //2
DWORD dwMinorVersion; //3
DWORD dwBuildNumber; //4
DWORD dwPlatformId; //5
TCHAR szCSDVersion[ 128 ]; //6
} OSVERSIONINFO;
#ce
$p = DllStructCreate("dword;dword;dword;dword;dword;char[128]")
;think of this as p->dwOSVersionInfoSize = sizeof(OSVERSIONINFO)
DllStructSetData($p, 1, DllStructGetSize($p))
;make the DllCall
$ret = DllCall("kernel32.dll","int","GetVersionEx","ptr",DllStructGetPtr($p))
if Not $ret[0] Then
MsgBox(0,"DllCall Error","DllCall Failed")
exit
EndIf
;get the returned values
$major = DllStructGetData($p,2)
$minor = DllStructGetData($p,3)
$build = DllStructGetData($p,4)
$platform = DllStructGetData($p,5)
$version = DllStructGetData($p,6)
;free the struct
$p =0
msgbox(0,"","Major: " & $major & @CRLF & _
"Minor: " & $minor & @CRLF & _
"Build: " & $build & @CRLF & _
"Platform ID: " & $platform & @CRLF & _
"Version: " & $version)