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


; Create the DLL structure to use in the DLLCall function.
Local $tagOSVERSIONINFO = DllStructCreate('dword dwOSVersionInfoSize;dword dwMajorVersion;dword dwMinorVersion;dword dwBuildNumber;dword dwPlatformId;char szCSDVersion[128]')

; Update the 'size element' in the structure by using DllStructGetSize to retrieve the total size of the structure.
DllStructSetData($tagOSVERSIONINFO, 'dwOSVersionInfoSize', DllStructGetSize($tagOSVERSIONINFO))

; Call the API function 'GetVersionEx' using DLLCall and passing the structure.
Local $aReturn = DllCall('kernel32.dll', 'int', 'GetVersionEx', 'struct*', $tagOSVERSIONINFO)
If @error Or Not $aReturn[0] Then
    MsgBox(0, "DLLCall Error", "An error occurred when retrieving the Operating System information.")
EndIf

; Get specific data from the element strings.
Local $iMajorVersion = DllStructGetData($tagOSVERSIONINFO, 'dwMajorVersion')
Local $iMinorVersion = DllStructGetData($tagOSVERSIONINFO, 'dwMinorVersion')
Local $iBuildNumber = DllStructGetData($tagOSVERSIONINFO, 'dwBuildNumber')
Local $sServicePack = DllStructGetData($tagOSVERSIONINFO, 'szCSDVersion')

; Free the structure.
$tagOSVERSIONINFO = 0

MsgBox(0, "Operating System information", "Major version: " & $iMajorVersion & @CRLF & _
        "Minor version: " & $iMinorVersion & @CRLF & _
        "Build: " & $iBuildNumber & @CRLF & _
        "Service Pack: " & $sServicePack & @CRLF)