Lange Rede, kurzer Sinn: Man kann den Datentyp nur interpretieren, wenn man ihn nicht kennt.
Hier ein kleines Beispiel
Spoiler anzeigen
Global $tTestStruct = DllStructCreate("float") ; 4 Byte groß
Global $pTestStruct = DllStructGetPtr($tTestStruct)
DllStructSetData($tTestStruct, 1, -20.7) ; schreibe den Float-Wert -20.7 in den Speicher
Global $tInterpretation1 = DllStructCreate("BYTE[4]", $pTestStruct)
Global $tInterpretation2 = DllStructCreate("short[2]", $pTestStruct)
Global $tInterpretation3 = DllStructCreate("USHORT[2]", $pTestStruct)
Global $tInterpretation4 = DllStructCreate("int", $pTestStruct)
Global $tInterpretation5 = DllStructCreate("UINT", $pTestStruct)
ConsoleWrite("Interpretation1 - Byte 0: " & DllStructGetData($tInterpretation1, 1, 1) & @CRLF)
ConsoleWrite("Interpretation1 - Byte 1: " & DllStructGetData($tInterpretation1, 1, 2) & @CRLF)
ConsoleWrite("Interpretation1 - Byte 2: " & DllStructGetData($tInterpretation1, 1, 3) & @CRLF)
ConsoleWrite("Interpretation1 - Byte 3: " & DllStructGetData($tInterpretation1, 1, 4) & @CRLF)
ConsoleWrite(@CRLF)
[/autoit] [autoit][/autoit] [autoit]ConsoleWrite("Interpretation2 - short 0: " & DllStructGetData($tInterpretation2, 1, 1) & @CRLF)
ConsoleWrite("Interpretation2 - short 1: " & DllStructGetData($tInterpretation2, 1, 2) & @CRLF)
ConsoleWrite(@CRLF)
[/autoit] [autoit][/autoit] [autoit]ConsoleWrite("Interpretation3 - USHORT 0: " & DllStructGetData($tInterpretation3, 1, 1) & @CRLF)
ConsoleWrite("Interpretation3 - USHORT 1: " & DllStructGetData($tInterpretation3, 1, 2) & @CRLF)
ConsoleWrite(@CRLF)
[/autoit] [autoit][/autoit] [autoit]ConsoleWrite("Interpretation4 - int: " & DllStructGetData($tInterpretation4, 1) & @CRLF)
[/autoit] [autoit][/autoit] [autoit]ConsoleWrite(@CRLF)
[/autoit] [autoit][/autoit] [autoit]ConsoleWrite("Interpretation5 - UINT: " & DllStructGetData($tInterpretation5, 1) & @CRLF)
[/autoit]