One correction for Cookie: to do a bitwise NOT operation, you need to use "~" as opposed to "!", as in:
js code:
Get = Get & ~0x40000;
The boolean not will not give the wanted results:
- !0x40000: A non-zero number converts to boolean true. The "!" takes this boolean equivalent and returns the opposite.
Result: false (boolean).
- Get & false: The bitwise AND takes two integers, so the boolean false is converted to the number zero. Therefore the expression becomes equivalent to Get & 0 which will always evaluate to zero.
Final result: 0 (number).
The only case where this could produce a non-zero number is when the flag to be subtracted would be zero. Then, the boolean NOT operator would evaluate to true and the expression becomes
Get & 1. This gives 1 when the smallest bit is set or 0 if it's not.
I'm sure it was just a typo on Cookie's side but I thought it'd be better to properly explain what's wrong with it. Bitwise arithmetic is frequently used in the Windows API and more developers should be aware of it.