Post by bill tiePost by Jeroen Mostertbool boolValue = BitConverter.ToInt32(bytes, 0) != 0;
I did something similar. Jeroen, can you confirm that BOOL
- is of the type int,
- is 32-bit long,
- means logical True if the integer value is non-zero, thus it may be
positive or negative,
- means logical False if the integer value is zero.
Wellll, if you want to get pedantic: not exactly. BOOL is a 32-bit integer
(regardless of platform bitness) that, according to the rules of Win32,
*must* be either TRUE (defined as 1) or FALSE (defined as 0). So it's
stricter than a C BOOL. However, in practice the type is always used in
expressions like
BOOL x = ...;
if (x) { ... }
which obeys the rules of C boolean testing, of course, meaning that any
nonzero value is true and zero is false (C didn't get a separate boolean
type until C99, which is not widely used). So the conversion as given above
will work for BOOLs that obey the rules and BOOLs that don't obey the Win32
rules but will work in practice.
When generating BOOL values yourself, you should of course take care to play
nice and produce only 0 and 1.
--
J.