# Function Reference

# _WinAPI_DisplayStruct

Displays data from the specified structure or memory address as a list

#include <WinAPIDiag.au3>
_WinAPI_DisplayStruct ( $tStruct [, $sStruct = '' [, $sTitle = '' [, $iItem = 0 [, $iSubItem = 0 [, $iFlags = 0 [, $bTop = True [, $hParent = 0]]]]]]] )

## Parameters

$tStruct | A structure that was created by DllStructCreate(), or memory address to be display its data.
$sStruct | [optional] A string representing the structure. If $tStruct is a structure, this parameter can be omitted or be an empty string. In this case, the structure will display as "byte[n]" structure. If $tStruct is a memory address, $sStruct should be a string representing the structure, otherwise, the function fail, and @error set to 10.
$sTitle | [optional] The title of the window, deault is "Structure: ListView Display".
$iItem | [optional] The 1-based index or name of the structure member to be selected in the list. If this parameter is 0 (Default), or an incorrect index or name, the first element of the structure will be selected.
$iSubItem | [optional] The 1-based index of the array in the structure member pointed to by the $iItem parameter to be selected. If $iItem was not defined as an array in the $sStruct, or invalid array index, the element pointed to by the $iItem parameter will be selected.
$iFlags | [optional] A set of bit flags that specifies an additional displaying options. This parameter can be 0, or any combination of the following values: 1 - Prevent displaying "<struct>" and "<endstruct>" fields at the beginning and end of the list. 2 - Prevent displaying "<alignment>" fields. 4 - Prevent displaying "<unnamed>" in "Member" column of the list if the structure element has no name. 8 - Prevent highlighting structure elements that are defined as an array. 16 - Prevent perceiving structure elements named "Reserved*" as unused elements. 32 - Prevent using double-click to copy values of the structure elements to the clipboard. 64 - Forced to expand structure elements of BYTE[n] and BOOLEAN[n] types (elements of CHAR[n] and WCHAR[n] types always displays as a string). 128 - Forced to display the values of the structure elements in the hexadecimal representation, if possible. 256 - Forced to return error code instead of displaying a message box if a memory access error occurred. 512 - Forced to disable checking the read access memory allocated to a given structure.
$bTop | [optional] Specifies whether create a window with "Always On Top" attribute, valid values: True - The window is created with the $WS_EX_TOPMOST extended style (Default). False - The window will not have the "TOPMOST" flag set.
$hParent | [optional] Handle to the parent window.

## Return Value

Success: | 1. @extended can be set see remark.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 2 - There is an unknown data type in the string passed. 3 - Failed to allocate the memory needed for the structure, or invalid pointer. 4 - Error allocating memory for the passed string. 10 - The $tStruct parameter is not a valid DllStruct. 15 - Error accessing memory to read data.

## Remarks

This function is intended primarily for debugging and should not be used in the final script, since no useful information for the end user does not carry.
When an element value contains '|', they are replaced by '¦' in the output as '|' is used internally during the creation of the output listview.
The @extended is set to 1 on return.

## Example

    #include <WinAPIDiag.au3>

    Local $sStruct = 'dword Length;short State;uint Flags;handle hBitmap;hwnd hDC;long Rect[4];byte[14];int Reserved[10];wchar Text[80];wchar Text[80]'
    Local $tStruct = DllStructCreate($sStruct)

    DllStructSetData($tStruct, 1, 80)
    DllStructSetData($tStruct, 2, 6)
    DllStructSetData($tStruct, 3, 1)
    DllStructSetData($tStruct, 4, 0x00010014)
    DllStructSetData($tStruct, 5, 0x01010057)
    DllStructSetData($tStruct, 6, 20, 1)
    DllStructSetData($tStruct, 6, 20, 2)
    DllStructSetData($tStruct, 6, 60, 3)
    DllStructSetData($tStruct, 6, 80, 4)
    DllStructSetData($tStruct, 7, Binary('0x656A6D633835206C6A6764206200'))
    DllStructSetData($tStruct, 8, 0)
    DllStructSetData($tStruct, 9, 'Simple Text')
    DllStructSetData($tStruct, 10, 'Text with | ...')

    _WinAPI_DisplayStruct($tStruct, $sStruct)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') Extended code: ' & @extended & @CRLF)