Status: Release/Final
Language: Visual Basic 6
Platform: Win9x, WinNT, Win2000/XP
Downloads: 68
Bitwise Operations is an app I created to assist in programming, particularly when using API function calls. As you may or may not know, many Windows API functions return or have parameters that are merely binary. The first byte might contain a virtual keycode while the next could hold the state of the key modifiers in single bits. Even if you ...
Bitwise Operations is an app I created to assist in programming, particularly when using API function calls. As you may or may not know, many Windows API functions return or have parameters that are merely binary. The first byte might contain a virtual keycode while the next could hold the state of the key modifiers in single bits. Even if you know how to use bitwise operators and what bits hold which information, it's hard to visualize the bits and convert them to the required hexadecimal or decimal number formats. This program allows you to convert between binary, hex, and decimal by allowing you to toggle each bit in 4 bytes or enter the number in the decimal and hex boxes. Then, through the use of my carefully crafted GUI, it's easy to take numbers you've entered and come up with a formula for extracting certain bits from function returns.
In the example screenshot, I have copied the decimal return from a function. Then, since I know that the data I'm looking for is in the third byte only, I show how to use the bitwise in hex to return only that byte and divide out the lower bytes. Then the final box shows the output of 30. There's also an option for using Or bitwise operations, but I haven't found a use for that yet.
The way you code bitwise operations in VB6 is to take the return and binary compare it to the value after the And operator, like this: (ret And &HFF0000)
If you want a bit, series of bits, or byte that is higher than the first bit, then you want to then divide by the lowest bit you have included in the last part, which would be like so: ret = ((ret And &HFF0000) / &H10000)
Hopefully, intermediate to advanced VB programmers like myself will find this program useful. It certainly saves much time doing calculations and conversions.
|