mattw112 Posted July 17, 2010 Share Posted July 17, 2010 I have a value in the registry of a PC for example: 0x00000191 I also have a known list of the Hex\Bit values that are tied to descriptions (simplified to letters for this example): Hex (Bit) - Description 0x00000001 (0) - A 0x00000002 (1) - B 0x00000010 (4) - C 0x00000020 (5) - D 0x00000040 (6) - E 0x00000080 (7) - F 0x00000100 (8) - G 0x00000200 (9) - H 0x00000400 (10) - I 0x00000800 (11) - J 0x00001000 (12) - K 0x00002000 (13) - L 0x00004000 (14) - M 0x00008000 (15) - N 0x00010000 (16) - O 0x00020000 (17) - P 0x00040000 (18) - Q 0x00080000 (19) - R 0x00100000 (20) - S 0x00200000 (21) - T 0x00400000 (22) - U 0x00800000 (23) - V 0x01000000 (24) - W 0x02000000 (25) - X 0x04000000 (26) - Y 0x08000000 (27) - Z 0x10000000 (28) - AA 0x20000000 (29) - BB 0x40000000 (30) - CC 0x80000000 (31) - DD Is there some command\UDF that can break the value from the registry down into the values from the list? For Example the return would be: A C F G If not what would be a good way of approaching this? Maybe start at the highest value and work through saying is this less than or equal to this number? If so capture the description and subtract the value, then on the new value go through the list again, ...etc? Thanks, Terry Link to comment Share on other sites More sharing options...
AndyG Posted July 17, 2010 Share Posted July 17, 2010 (edited) Hi, not an udf but not far away . I copied your "list" from your posting 0x00000001 (0) - A 0x00000002 (1) - B and so on... into a file named test.txt #include <Array.au3> Dim $array[30][4] ;[0-31] [0=hex 1=number 2=- 3=Letters ] $string = FileRead("test.txt") ;get 0x00000001 (0) - A and all the others.... $lines = StringSplit($string, @CRLF, 3) ;splits file into lines For $i = 0 To UBound($lines) - 1 ;each line $a = StringSplit($lines[$i], " ", 3) ;split into items For $z = 0 To UBound($a) - 1 ;all items $array[$i][$z] = $a[$z] ;all items into array Next Next Dim $examples[3] = [0x181, 0x21008421, 0x40020022] For $i = 0 To UBound($examples) - 1 ;examples $letters = _hextoletters($examples[$i]) MsgBox(0, Hex($examples[$i]), $letters) Next Func _HexToLetters($hex) ;returns the letters Local $letters = "" For $i = 0 To 29 ;all hex´es If BitAND($hex, $array[$i][0]) = $array[$i][0] Then $letters &= $array[$i][3] ;compare hex from array with example, if equal, get letter Next Return $letters EndFunc ;==>_HexToLetters hope this is what you are looking for... Edited July 17, 2010 by AndyG Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 18, 2010 Share Posted July 18, 2010 Or maybe: Global $aDefinitions[32], $sInput, $iInput, $sMsg For $n = 0 To UBound($aDefinitions) -1 $aDefinitions[$n] = "Definition for bit: " & $n Next While 1 $sInput = InputBox("Test", "Enter INT32 value: ") If @error Or ($sInput = "") Then Exit $iInput = Int(Execute($sInput)) If $iInput Then $sMsg = "$sInput = " & $sInput & " = " & $iInput & " = 0x" & Hex($iInput) For $n = 0 To 31 If BitAND($iInput, 2^$n) Then $sMsg &= @CRLF & @TAB & "Bit " & $n & " set (" & 2^$n & ") = " & $aDefinitions[$n] EndIf Next MsgBox(64, "Results", $sMsg) Else MsgBox(16, "Error", "Input = 0, no bits set") EndIf WEnd Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
mattw112 Posted July 19, 2010 Author Share Posted July 19, 2010 PSaltyDS, this worked perfectly!! Thanks, Terry Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now