Jump to content

Sunev_C

Members
  • Posts

    2
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Sunev_C's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thank you Nine, _WinAPI_DisplayStruct() clearly tells me that those SHORT and FLOAT are saved correctly in memory. And thank you RTFC, these docs really helped me, I changed my code as below, and it works. Local $short = DllStructCreate("SHORT a") Local $int = DllStructCreate("INT a") Local $float = DllStructCreate("FLOAT a") Local $double = DllStructCreate("DOUBLE a") ; share memory Local $byte_2_for_short = DllStructCreate("BYTE[2]", DllStructGetPtr($short)) Local $byte_4_for_int = DllStructCreate("BYTE[4]", DllStructGetPtr($int)) Local $byte_4_for_float = DllStructCreate("BYTE[4]", DllStructGetPtr($float)) Local $byte_8_for_double = DllStructCreate("BYTE[8]", DllStructGetPtr($double)) ConsoleWrite("short size: " & DllStructGetSize($short) & " bytes" & @CRLF) ;~ should be 2 ConsoleWrite("int size: " & DllStructGetSize($int) & " bytes" & @CRLF) ;~ should be 4 ConsoleWrite("float size: " & DllStructGetSize($float) & " bytes" & @CRLF) ;~ should be 4 ConsoleWrite("double size: " & DllStructGetSize($double) & " bytes" & @CRLF) ;~ should be 8 $short.a = 1 $int.a = 1 $float.a = 1 $double.a = 1 ; returns binary type values now. They are in little-endian style on my PC, but it won't be big problem for me. Local $hexStringForShort = DllStructGetData($byte_2_for_short, 1) Local $hexStringForInt = DllStructGetData($byte_4_for_int, 1) Local $hexStringForFloat = DllStructGetData($byte_4_for_float, 1) Local $hexStringForDouble = DllStructGetData($byte_8_for_double, 1) ConsoleWrite("short Hex: 0x" & Hex($hexStringForShort) & @CRLF) ;~ should be 0x0001 ConsoleWrite("int Hex: 0x" & Hex($hexStringForInt) & @CRLF) ;~ should be 0x00000001 ConsoleWrite("float Hex: 0x" & Hex($hexStringForFloat) & @CRLF) ;~ should be 0x3f800000 ConsoleWrite("double Hex: 0x" & Hex($hexStringForDouble) & @CRLF) ;~ should be 0x3ff0000000000000 Thank you both again!
  2. I want to get hex string of a value, that's why I tried DllStructCreate() The defined short should have been 2 bytes, but a 4-byte int type was returned. The defined float should have been 4 bytes, but an 8-byte double type was returned. Local $short = DllStructCreate("SHORT a") Local $int = DllStructCreate("INT a") Local $float = DllStructCreate("FLOAT a") Local $double = DllStructCreate("DOUBLE a") ConsoleWrite("short size: " & BinaryLen($short.a) & " bytes" & @CRLF) ;~ should be 2, got 4 ConsoleWrite("int size: " & BinaryLen($int.a) & " bytes" & @CRLF) ;~ should be 4 ConsoleWrite("float size: " & BinaryLen($float.a) & " bytes" & @CRLF) ;~ should be 4, got 8 ConsoleWrite("double size: " & BinaryLen($double.a) & " bytes" & @CRLF) ;~ should be 8 $short.a = 1 $int.a = 1 $float.a = 1 $double.a = 1 ConsoleWrite("short value: " & $short.a & @CRLF) ConsoleWrite("int value: " & $int.a & @CRLF) ConsoleWrite("float value: " & $float.a & @CRLF) ConsoleWrite("double value: " & $double.a & @CRLF) ConsoleWrite("short Hex: 0x" & Hex($short.a) & @CRLF) ;~ should be 0x0001 ConsoleWrite("int Hex: 0x" & Hex($int.a) & @CRLF) ;~ should be 0x00000001 ConsoleWrite("float Hex: 0x" & Hex($float.a) & @CRLF) ;~ should be 0x3f800000 ConsoleWrite("double Hex: 0x" & Hex($double.a) & @CRLF) ;~ should be 0x3ff0000000000000 I'm using Autoit v3.3.16.1. What's going on? What did I do wrong?
×
×
  • Create New...