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 or the elementname as defined in DllStructCreate.
index [optional] For elements that are an array this specifies the 1-based index to retrieve. if omitted or the Default keyword then the entire array is retrieved (Useful for quickly retrieving strings). Not used for non-array elements.
*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 binary type,
otherwise it always returns a number.

 

Related

DllStructCreate, DllStructSetData

 

Example


$p  = DllStructCreate("dword dwOSVersionInfoSize;dword dwMajorVersion;dword dwMinorVersion;dword dwBuildNumber;dword dwPlatformId;char szCSDVersion[128]")

;think of this as p->dwOSVersionInfoSize = sizeof(OSVERSIONINFO)
DllStructSetData($p, "dwOSVersionInfoSize", 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,"dwMajorVersion")
$minor      = DllStructGetData($p,"dwMinorVersion")
$build      = DllStructGetData($p,"dwBuildNumber")
$platform   = DllStructGetData($p,"dwPlatformId")
$version    = DllStructGetData($p,"szCSDVersion")

;free the struct
$p =0

msgbox(0,"","Major: " & $major & @CRLF & _
            "Minor: " & $minor & @CRLF & _
            "Build: " & $build & @CRLF & _
            "Platform ID: " & $platform & @CRLF & _
            "Version: " & $version)