0

As said here Microsoft docs - CreateFileA function

dwDesiredAccess

The requested access to the file or device, which can be summarized as read, write, both or neither zero).

The most commonly used values are GENERIC_READ, GENERIC_WRITE, or both (GENERIC_READ | GENERIC_WRITE)

When using both READ and WRITE permissions, why is it written GENERIC_READ | GENERIC_WRITE and not GENERIC_READ && GENERIC_WRITE? Does the | has anything to do with the bitwise OR operator? if yes, why do we use that instead of &&?

Swordfish
  • 12,971
  • 3
  • 21
  • 43
ElayM
  • 66
  • 1
  • 7

1 Answers1

0

GENERIC_READ and GENERIC_WRITE are bit flags - values that only have one bit set. To combine them you use the bitwise or operator |. && is not a bitwise operator, but a logic operator.

Swordfish
  • 12,971
  • 3
  • 21
  • 43