From: Nobody on
"Henning" <computer_hero(a)coldmail.com> wrote in message
news:esdPXeWxKHA.4492(a)TK2MSFTNGP05.phx.gbl...
> This could also be written as If (struct.flags And LLKHF_INJECTED) =
> LLKHF_INJECTED Then.

That syntax is fine, and I used to do that, but not anymore. When I want to
test another flag, I have to replace both instances of "LLKHF_INJECTED". If
I used "<> 0", I would need only to replace one. What I am trying to allude
to here is that it's common to add more checks later. For example, if you
have this line of code:

If (struct.flags And LLKHF_INJECTED) Then

And you decided to add another check, such as IsWindowVisible():

If (struct.flags And LLKHF_INJECTED) And IsWindowVisible(hWnd) Then

Since the first part would be either 0 or 16, and IsWindowVisible() returns
either 0 or +1, the overall result is always 0. One way to avoid this is by
using "= 0 " or "<> 0", or CBool(). For me, when I see that "= 0 ","<>
0",CBool() are missing, I see a potential bug waiting to bite someone later.


From: Bob O`Bob on
Henning wrote:

>
> This could also be written as If (struct.flags And LLKHF_INJECTED) =
> LLKHF_INJECTED Then.
>


Yes, and when my priority is on code readability
over performance, that's probably a preferred choice.

I just have the feeling that in the general case it
runs slower, though if it's a CONST I could believe
the difference might get compiled away.



Bob
--